云泥
云泥
这是 useSelections 不支持"非基础类型的项"(例如:对象作为数组项)导致的,示例代码中的用法:`[{ a: 1 }, { a: 2 }]` [目前是不支持这样的使用的](https://github.com/alibaba/hooks/issues/1105)。 目前这个 PR 只是绕过了根本问题而做的临时解决,不太推荐。 **可以让 useSelections 支持复杂类型的项,可以来个新 PR**,这样这个 PR 对应的问题自然就没了。
> @liuyib 这个问题应该和对象数组没关系,改成int数组也是成立的。 究其原因是items入参数据被改变。state 中始终有上一次的数据,无法被清除。 而源数组被改变的场景也很普遍,如翻页或tabs list。 我不认为应该 close。 确实如你所说,之前看的不够仔细
我更新下 unSelectAll, clearAll 的文档解释,目前看不出区别
> @liuyib 其实 items 是支持 object[] 的,函数内部实现用 set。判断 isSelected 等也有没问题。 保证 object 不变即可。 const list = [{a: 1}, {b: 2}]; const set = new Set(); > > set.add(list[0]); set.has(list[0]); //...
等有权限的大佬合并,大佬在忙,等吧
React has removed this warning in v18, please see: https://github.com/reactwg/react-18/discussions/82 In React < v18, please ignore this warning.
截图的报错和 https://github.com/reactwg/react-18/discussions/82 里的报错: > Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix,...
@1zilc 多谢提供 demo,但是没有复现
> 可能的 API 为 `refresh(force: boolean): void` 或者 `refresh(options?: { skipStaleTime:? boolean }): void` 是有这种场景,可以考虑支持
please try this: ```ts setUrlState((prevState) => ({ ...prevState, foo: 'bar' })); ```