@reacthooks.org/use-session-storage

1.0.8 • Public • Published

Install

$ npm install @reacthooks.org/use-session-storage

useSessionStorage

A React Hook which sets/gets a value in window.sessionStorage.

Synopsis

In your React component:

import { useState } from 'react'
import useSessionStorage from "use-session-storage"

function Skeleton() {
  // set the value in sessionStorage upon initialisation
  const [ salutation, setSalutation ] = useSessionStorage("salutation", "Hello")

  // don't set the value but instead retrieve what is in sessionStorage()
  const [ name, setName ] = useSessionStorage("name")

  return <p>{ salutation } { name }</p>
}

Other Hooks

Please see all of the other reacthooks.org hooks:

Author

$ npx chilts

   ╒════════════════════════════════════════════════════╕
   │                                                    │
   │   Andrew Chilton (Personal)                        │
   │   -------------------------                        │
   │                                                    │
   │          Email : andychilton@gmail.com             │
   │            Web : https://chilts.org                │
   │        Twitter : https://twitter.com/andychilton   │
   │         GitHub : https://github.com/chilts         │
   │         GitLab : https://gitlab.org/chilts         │
   │                                                    │
   │   Apps Attic Ltd (My Company)                      │
   │   ---------------------------                      │
   │                                                    │
   │          Email : chilts@appsattic.com              │
   │            Web : https://appsattic.com             │
   │        Twitter : https://twitter.com/AppsAttic     │
   │         GitLab : https://gitlab.com/appsattic      │
   │                                                    │
   │   Node.js / npm                                    │
   │   -------------                                    │
   │                                                    │
   │        Profile : https://www.npmjs.com/~chilts     │
   │           Card : $ npx chilts                      │
   │                                                    │
   ╘════════════════════════════════════════════════════╛

(Ends)

Package Sidebar

Install

npm i @reacthooks.org/use-session-storage

Weekly Downloads

0

Version

1.0.8

License

ISC

Unpacked Size

7.65 kB

Total Files

5

Last publish

Collaborators

  • chilts
  • chilts-appsattic