-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
[utils] Port useLocalStorageState hook from Toolpad
#41096
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
Conversation
| const upperTheme = useTheme(); | ||
| const changeTheme = useChangeTheme(); | ||
| const [mode, setMode] = React.useState(null); | ||
| const [mode, setMode] = useLocalStorageState('mui-mode', 'system'); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Netlify deploy previewhttps://deploy-preview-41096--material-ui.netlify.app/ Bundle size report |
|
Changes like this one create an extra incentive to solve #35840. |
useLocalStorageState hook from Toolpad
bharatkashyap
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
siriwatknp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does useLocalStorageState need to be exported from @mui/utils?
|
I was planning to replace our usage in toolpad with this implementation. X was also investigating whether they could provide datagrid persistence on top of it. |
What if it was Toolpad's scope to deliver this? Maybe that module could also have an adapter for TanStack Table, for AG Grid. |
siriwatknp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I think let's reexport from @mui/utils too for consistency.
Signed-off-by: Jan Potoms <[email protected]>
|
This introduces regressions:
https://deploy-preview-41096--material-ui.netlify.app/
|
|
3rd regressions: which I can reproduce on https://deploy-preview-41096--material-ui.netlify.app/material-ui/react-button/ and in localhost: RDvmpjl0rr2F38jr.mp4For example: https://twitter.com/apoorv_taneja/status/1761292886052884955. I have reverted with 0d086a1. |
This reverts commit b923a63. See for why #41096 (comment)
Signed-off-by: Jan Potoms <[email protected]>
Signed-off-by: Jan Potoms <[email protected]>
)" This reverts commit b923a63. See for why mui#41096 (comment)

As per mui/mui-x#11576 (comment)
useLocalStorageStatehook from Toolpad.Immediate improvements this hook brings to the docs
Easier to reason about
Package manager now switches across the page
Screen.Recording.2024-02-14.at.15.52.32.mp4
https://deploy-preview-41096--material-ui.netlify.app/material-ui/getting-started/installation/
Theme now switches across opened tabs
Screen.Recording.2024-02-14.at.16.12.47.1.mp4