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

React.StrictMode 模式下组件内会陷入死循环 #56

Open
AmorDiamond opened this issue Sep 2, 2024 · 5 comments
Open

React.StrictMode 模式下组件内会陷入死循环 #56

AmorDiamond opened this issue Sep 2, 2024 · 5 comments

Comments

@AmorDiamond
Copy link

image

@wangzongming
Copy link
Owner

是不是因为调用 setValue 的时机不对?或者传给组件 value 时候没有做好控制。

@AmorDiamond
Copy link
Author

AmorDiamond commented Sep 2, 2024

是不是因为调用 setValue 的时机不对?或者传给组件 value 时候没有做好控制。

https://codesandbox.io/p/sandbox/yttkt6?file=%2Fsrc%2FCronFormInput.js%3A6%2C47

使用方式的代码可以参考这个

@AmorDiamond
Copy link
Author

https://codesandbox.io/p/sandbox/yttkt6?file=%2Fsrc%2FCronFormInput.js%3A6%2C47

image

面板需要切换到 “分”,因为默认值只设置了“分”

@AmorDiamond
Copy link
Author

image

React 18 React.StrictMode模式下,这里还是会循环执行。

组件销毁的时候把 isFirstRender ref 数据重置一下应该就可以了

image

@wangzongming
Copy link
Owner

感谢反馈,r18在开发环境下确实会重复两次 useEffect 等我改下。

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

2 participants