LocalStorage on Vite gets cleared on every refresh #14826
-
LocalStorage on Vite gets cleared on every refreshI am doing a Todo app where users' data(todos) will be stored on localStorage and display the data when page is refreshed or reopened. But I had this issue that when user refreshes page, localStorage gets cleared. I couldn't be able to solve the problem no matter what I tried. I am pretty sure that my code is not the problem because I copied my components and stuff to newly created create-react-app project and it worked. Then I copied the same files to newly created Vite project and same problem happened again. I installed Vite with React framework and selected only JavaScript and then I installed Tailwindcss. Reproductionhttps://github.com/Jupkobe/vite-localstorage-bug Steps to reproducenpm install System InfoSystem:
OS: Windows 10 10.0.19045
CPU: (8) x64 Intel(R) Core(TM) i5-10300H CPU @ 2.50GHz
Memory: 7.35 GB / 15.87 GB
Binaries:
Node: 21.0.0 - C:\Program Files\nodejs\node.EXE
npm: 10.2.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.19041.3570.0), Chromium (118.0.2088.76)
Internet Explorer: 11.0.19041.3570
npmPackages:
@vitejs/plugin-react: ^4.0.3 => 4.1.0
vite: ^4.4.5 => 4.5.0 Used Package Managernpm LogsNo response Validations
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You are clearing it here. |
Beta Was this translation helpful? Give feedback.
You are clearing it here.
https://github.com/Jupkobe/vite-localstorage-bug/blob/aee75f637c49b5a371daeeab81b5e41772f47920/src/main.jsx#L6