Socket
Book a DemoInstallSign in
Socket

uselocalstorage-react-hook

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uselocalstorage-react-hook

Use local storage in react

latest
Source
npmnpm
Version
1.0.5
Version published
Maintainers
1
Created
Source

NPM

Uselocalstorage-React-Hook

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

🛠️ Installation

  • Install using npm
npm i uselocalstorage-react-hook
  • Add to your project
import useLocalStorage from "uselocalstorage-react-hook";
  • 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.

Keywords

uselocalstorage-react

FAQs

Package last updated on 14 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts