Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[useSetState] 深层对象是否应该按需合并 #2707

Open
yangliguo7 opened this issue Dec 25, 2024 · 0 comments
Open

[useSetState] 深层对象是否应该按需合并 #2707

yangliguo7 opened this issue Dec 25, 2024 · 0 comments

Comments

@yangliguo7
Copy link

源码这里只是简单的使用扩展运算符做对象的覆盖

return newState ? { ...prevState, ...newState } : prevState;

如果只想对层级深的对象的某个值变更就会有问题,例如:https://codesandbox.io/p/sandbox/ji-chu-yong-fa-forked-qsglr8?file=%2Findex.html

点击按钮的的时候 只想修改对象某个key下的具体值,但是会覆盖所有的数据。

我不确定这是不是一个问题,可能你们当初设计的就是如此,如果这是一个问题话,我可以提个PR修复。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant