mui / mui-x

MUI X: Build complex and data-rich applications using a growing list of advanced React components, like the Data Grid, Date and Time Pickers, Charts, and more!
https://mui.com/x/
4.15k stars 1.3k forks source link

[data grid] How do I Export The Save State Item To LocalStorage #12291

Closed lisaWriteJava closed 7 months ago

lisaWriteJava commented 7 months ago

The problem in depth

Ok, I'd like to get this example: https://codesandbox.io/p/sandbox/shy-paper-8cngkv?file=%2Fsrc%2FDemo.js%3A180%2C27 from the examples to save to local storage. It never calls localStorage.setItem like this example https://codesandbox.io/p/sandbox/vibrant-johnson-5gzqgz?file=%2Fsrc%2FDemo.js%3A20%2C7-20%2C27

I got both of these from the documentation.

Your environment

`npx @mui/envinfo` ``` System: OS: Linux 3.10 CentOS Linux 7 (Core) Binaries: Node: 16.20.0 - ~/.nvm/versions/node/v16.20.0/bin/node npm: 7.24.2 - ~/node_modules/.bin/npm pnpm: Not Found Browsers: Chrome: 120.0.6099.71 npmPackages: @emotion/react: latest => 11.11.3 @emotion/styled: latest => 11.11.0 @mui/base: 5.0.0-beta.32 @mui/core-downloads-tracker: 5.15.5 @mui/icons-material: ^5.15.3 => 5.15.5 @mui/lab: ^5.0.0-alpha.159 => 5.0.0-alpha.161 @mui/material: ^5.15.3 => 5.15.5 @mui/private-theming: 5.15.5 @mui/styled-engine: 5.15.5 @mui/styles: ^5.15.3 => 5.15.5 @mui/system: 5.15.5 @mui/types: 7.2.13 @mui/utils: ^5.15.4 => 5.15.5 @mui/x-data-grid: 6.19.1 @mui/x-data-grid-generator: ^6.16.2 => 6.19.1 @mui/x-data-grid-premium: ^6.19.1 => 6.19.1 @mui/x-data-grid-pro: 6.19.1 @mui/x-license-pro: ^6.10.2 => 6.10.2 @types/react: 17.0.75 react: ^17.0.2 => 17.0.2 react-dom: ^17.0.2 => 17.0.2 styled-components: latest => 6.1.8 ```

Search keywords: localStorage Order ID: 66765

michelengelen commented 7 months ago

Hey @lisaWriteJava what exactly are you trying to do? The first example you gave is not using localStorage at all, only internal state.

Please provide a more detailed explanation and, when possible, a minimal reproduction example.

lisaWriteJava commented 7 months ago

Yes, I'd like to find out how to change the 1st example to use localstorage instead of internal storage like the 2nd.

michelengelen commented 7 months ago

You just have to replace the usage of useReducer with using localStorage. But this specific problem is unrelated to our components. Please use StackOverflow for implementation specific questions like these.

github-actions[bot] commented 7 months ago

👋 Thanks for using MUI X!

We use GitHub issues as a bug and feature requests tracker, however, this issue appears to be a support request.

For support, please check out https://mui.com/x/introduction/support/. Thanks!

If you have a question on Stack Overflow, you are welcome to link to it here, it might help others. If your issue is subsequently confirmed as a bug, and the report follows the issue template, it can be reopened.