useSessionstorageState

About

useState but syncs with sessionstorage

Examples

import "./styles.css";
import React from "react";
import { useSessionstorageState } from "rooks";

export default function App() {
  const [count, setCount] = useSessionstorageState("my-app:count", 0);

  return (
    <div className="App">
      <h1>Rooks : useSessionstorageState</h1>
      <p> Refresh the page to see the previous value in tact</p>
      <button onClick={() => setCount(0)}>clear</button>
      <button onClick={() => setCount(count + 1)}>Click me {count}</button>
    </div>
  );
}

Join the community!

Join our discord server! You can click the floating discord icon at the bottom right of the screen and chat with us!

Powered by vercel