Skip to content
Advertisement

React – how to apply local storage for hook value

I use the react-range package for personal purposes of my project, the problem is that I cannot save the value when the page is refreshed, I tried to use the local storage but I could not

As you understand, I need to save the value using local storage, in addition, I will leave a link to mine on codesandbox link

SideBarBlurChange.jsx

JavaScript

Advertisement

Answer

I think your main problem was that localStorage doesn’t store anything besides strings. You’re going to want to parseInt then check to make sure localStorage isn’t null. Can you try this and see if it works?

JavaScript
Advertisement