This repository has been archived by the owner on Dec 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
Invariant Violation: Maximum update depth exceeded when using setParams #35
Comments
This is true, and I'll fix this as soon as I have a good developer setup Also => #3 |
Any update on this? |
@iamgerardm the issue to check is #40 It's not so clear how to solve this issue, I've tried to see with the React team what the reco here: facebook/react#16956 One solution is to expose a navigation ref, always stable: const navigationRef= useNavigationRef();
useEffect(() => {
navigationRef.setParams({ myParam: 'myValue' });
}, [navigationRef]); I don't know if we want to ship such a public api, it feels a bit weird. In the meantime you can create const useNavigationRef = () => {
const navigation = useNavigation
const ref = useRef(navigation);
useLayoutEffect(() => {
ref.current = navigation;
});
return ref;
}; |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
causes
Invariant Violation: Maximum update depth exceeded
. And when using best practices according toeslint-plugin-react-hooks
this dependency is automatically added. I suggest:eslint-plugin-react-hooks
works, but would of course be great if it wouldn't include something like setParams automatically. For setState this is the case - maybe using setState under the hood would make it smarter? Otherwise it's probably outside the scope of this package! :)The text was updated successfully, but these errors were encountered: