New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@rickbrown/use-local-storage

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rickbrown/use-local-storage

A custom React hook to simplify using local storage.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-85.71%
Maintainers
1
Weekly downloads
 
Created
Source

@rickbrown/use-local-storage

NPM JavaScript Style Guide

Description

useLocalStorage is a custom React hook, which simplifies using the browsers local storage, when developing React applications.

Installation

Use the package manager yarn to install the useLocalStorage hook.

yarn add @rickbrown/use-local-storage

Usage

import { useLocalStorage } from '@rickbrown/use-local-storage'

const Example = () => {
  // Optionally accepts 2 arguments for its initial value.
  // ('key','value')
  const [name, setName] = useLocalStorage()
  
  const [newName, setNewName] = React.useState('')

  return (
    <div>
      <p>Current value in local storage: {name}</p>
      <input
        type="text"
        placeholder="Enter your name"
        value={newName}
        onChange={e => setNewName(e.target.value)}
      />
      <button onClick={() => setName(newName)}>
        Click To Update Local Storage
      </button>
    </div>
  )
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

FAQs

Package last updated on 19 Dec 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc