Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function UseLocalstorageDemo() {
const [myValue, setMyValue, removeMyValue] = useLocalstorage("my-value", 0);
return (
<>
<h1>Please check localstorage for changes</h1>
<p>
Value is {myValue}
<button> setMyValue(myValue !== null ? myValue + 1 : 0)}>
Increment
</button>
<button>Remove </button>
</p>
);
}
function UseLocalstorageDemoObject() {
const { value, set, remove } = useLocalstorage("my-value", 0);
return (
<>
<h1>Please check localstorage for changes</h1>
<p>
Value is {value}
<button> set(value !== null ? value + 1 : 0)}>
Increment
</button>
<button>Remove </button>
</p>
);
}