Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@d2k/react-localstorage

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@d2k/react-localstorage

React hooks for localstorage

  • 1.0.6
  • Source
  • npm
  • Socket score

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

@d2k/react-localstorage

React hooks for easy and simple localstorage access

You'll need to install react, react-dom, etc at ^16.8.4

Install

npm i @d2k/react-localstorage --save

Usage

React Localstorage gives you simple hooks to work with your localstorage. Here is some example code:

import React from 'react
import useLocalStorage from '@d2k/react-localstorage'

const App = () => {
  const firstName = useLocalStorage('firstName', 'John')
  const lastName = useLocalStorage('lastName', 'Doe')

  // You can update localStorage data via firstName.set(val) or firstName.remove()

  return (
    <h1>Demo</h1>
    { firstName.data && lastName.data && (
      <p>
        Hello {firstName.data} {lastName.data}
      </p>
    )}
  )
}

Use .set or .remove to update data from your component.

All storage updates will be automatically synced with all components using the same localStorage value key.

Keywords

FAQs

Package last updated on 05 Oct 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