-
Notifications
You must be signed in to change notification settings - Fork 35
Investigate hook caching #3
Comments
I get an infinite loop if I pass function ReactComponent() {
const {navigate} = useNavigation();
useEffect(() => {
if (user) {
navigate(...)
}
}, [user, navigate])
return null
}
My solution, for now, is to not pass The link you posted is broken FYI |
The link is old. Yes there's a problem, I'll solve it as soon as I can. Need to have a proper dev setup first (if you want to help => #28) |
Oh, actually navigate() comes from the ReactNavigation context, so it should rather be cached in core |
@cmmartin the original issue is not totally related to your problem. I've opened a new issue in core for that: https://github.com/react-navigation/core/issues/71 The original issue will be fixed by #3 |
should be fixed by release 1.0.3 and #38, please tell me if everything works |
@cmmartin ,relative to this issue: https://github.com/react-navigation/core/issues/71 Can you help us understand what you are trying to achieve exactly with the following code? function ReactComponent() {
const {navigate} = useNavigation();
useEffect(() => {
if (user) {
navigate(...)
}
}, [user, navigate])
return null
} Is it something related to switching from authenticated / non authenticated navigators? |
Ideally we would be providing the navigation state key to the useEffect hook, but it causes the events to be missed because re-subscription happens frequently.
See for context: https://github.com/react-navigation/react-navigation-hooks/blob/master/src/Hooks.js#L37-L42
Can somebody help investigate if we are doing the right thing here?
The text was updated successfully, but these errors were encountered: