Woodworker4303

Woodworker4303 Repositories

Check outuselocalstorage-react-hook on Github stars 0

NPM

Uselocalstorage-React-Hook

This is an amazing package that will help you add local storage variables easily in your react app.

🛠️ Installation

  1. Install using npm
npm i uselocalstorage-react-hook
  1. Add to your project
import useLocalStorage from "uselocalstorage-react-hook";
  1. Start using uselocalstorage-react-hook
const [name, setName] = useLocalStorage("name", "John Doe");

💻 Example Code

import React from "react";
import "./styles.css";
import useLocalStorage from "uselocalstorage-react-hook";

const App = () => {
  const [name, setName] = useLocalStorage("name", "John Doe");

  return (
    <div>
      <input
        type="text"
        value={name}
        onChange={(e) => setName(e.target.value)}
      />
      <h1>{name}</h1>
      <p>Refresh this page, the name remains the same. 🤟</p>
    </div>
  );
};

export default App;

🦄 Live Demo

🙌 Thanks

Thanks to everyone who contributed to the development of this project.

If you enjoyed, go follow me on Twitter 💖

🛡️ License

MIT Licensed. Copyright (c) Savio Martin.