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