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

feat(ra-core): remove useSafeSetState hook #10341

Merged
merged 5 commits into from
Nov 14, 2024

Conversation

geobde
Copy link
Contributor

@geobde geobde commented Nov 10, 2024

Problem
The useSafeSetState hook was previously used to prevent warnings when attempting to call setState on unmounted components. However, with React 18 changes the use of this hook has become unnecessary and leads to unnecessary complexity.

Solution
Replaced the useSafeSetState hook with the React.useState. Since React no longer issues warnings when calling setState on unmounted components.

Context
Update to remove the "setState on unmounted component" warning

Closes #10323

@geobde geobde changed the title feat(ra-core): remove useSafeSetState and use React.useState instead feat(ra-core): remove useSafeSetState Nov 10, 2024
@geobde geobde changed the title feat(ra-core): remove useSafeSetState feat(ra-core): remove useSafeSetState hook Nov 10, 2024
examples/crm/src/login/LoginForm.tsx Show resolved Hide resolved
examples/crm/src/login/LoginForm.tsx Outdated Show resolved Hide resolved
packages/ra-core/src/auth/useLogoutIfAccessDenied.spec.tsx Outdated Show resolved Hide resolved
examples/crm/src/login/LoginForm.tsx Outdated Show resolved Hide resolved
packages/ra-core/src/util/hooks.ts Show resolved Hide resolved
@djhi djhi added this to the 5.3.4 milestone Nov 14, 2024
@fzaninotto
Copy link
Member

We still support react 17. What about people still using it?

No, react-admin v5 requires React 18.

https://marmelab.com/react-admin/Upgrade.html#react-18

@djhi djhi merged commit 3eb11c3 into marmelab:next Nov 14, 2024
14 checks passed
@djhi
Copy link
Collaborator

djhi commented Nov 14, 2024

Thanks!

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 this pull request may close these issues.

4 participants