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
refactor: Remove the unnecessary logic #1928
refactor: Remove the unnecessary logic #1928
Conversation
|
这个逻辑确实没啥用... |
辛苦帮忙补个单侧... |
How can I do for it? This change should not need to add additional tests? |
The value of the ref should be false after the component is unmounted and then remounted? |
@hchlq Hi, My friend~~ I think don't need this case? because the React will reinit react hook state when the component is mounted. |
Get it. If not, it's not necessary. |
LGTM |
Here is a problem in react 18 StrictMode, effects will run twice in development, see beta website // react 18 StrictMode
// effect created
unmountedRef => false
// effect destoryed
unmountedRef => true
// effect created
unmountedRef => true you can see, it's necessary |
This reverts commit 1f2c1b4.
Oh, So Sorry~ |
🤔 This is a ...
🔗 Related issue link
#1927
💡 Background and solution
const useUnmountedRef = () => { const unmountedRef = useRef(false); useEffect(() => { - unmountedRef.current = false; return () => { unmountedRef.current = true; }; }, []); return unmountedRef; };
📝 Changelog
unmountedRef
中非必要的逻辑,以优化性能☑️ Self Check before Merge