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

Invalid isMount behavior in React.StrictMode #186

Open
undermuz opened this issue Feb 11, 2025 · 0 comments · May be fixed by #187
Open

Invalid isMount behavior in React.StrictMode #186

undermuz opened this issue Feb 11, 2025 · 0 comments · May be fixed by #187

Comments

@undermuz
Copy link

https://react.dev/reference/react/StrictMode

Image

Using React StrictMode causes effects to re-run an extra time to find bugs caused by missing effect cleanup. This causes the following code to not work as expected: https://github.com/atlassian/pragmatic-drag-and-drop/blob/main/packages/react-beautiful-dnd-migration/src/draggable/index.tsx#L250

const isMountedRef = useRef(true);
	useEffect(() => {
		return () => {
			isMountedRef.current = false;
		};
	}, []);

This code throws an error in development mode: https://github.com/atlassian/pragmatic-drag-and-drop/blob/main/packages/react-beautiful-dnd-migration/src/draggable/index.tsx#L422

rbdInvariant(isMountedRef.current, 'isMounted onBeforeDragEnd');

Image

@undermuz undermuz linked a pull request Feb 11, 2025 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant