1.0.0 • Published 1 year ago

@micromint1npm/sed-eos-reprehenderit v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

sessionstate

NPM JavaScript Style Guide

Install

npm install --save sessionstate

Description

This simple hook should make it easier to add JSON and string objects to the window sessionStorage variable using useState.

Usage

// string

import React, { useEffect } from 'react'

import { useSessionState } from 'sessionstate'

const Example = () => {
  const [state, setState] = useSessionState("window.sessionStorage variable")
  useEffect(()=>{
    console.log("sessionStorage: " + window.sessionStorage["window.sessionStorage variable"])
    console.log("sessionState: " + state)
  }, [state])
  return (
    <div>      
      <p>{state}</p>
      <button onClick={()=>setState("Your value")}>Save value</button>
    </div>
  )
}

// JSON

import React, { useEffect } from 'react'

import { useSessionState } from 'sessionstate'

const Example = () => {
  const [state, setState] = useSessionState("window.sessionStorage variable")
  useEffect(()=>{
    console.log("sessionStorage: " + window.sessionStorage["window.sessionStorage variable"])
    console.log("sessionState: " + state)
  }, [state])
  return (
    <div>      
      <p>{state}</p>
      <button onClick={()=>setState([{"key1": "value1"}, {"key2": "value2"}])}>Save value</button>
    </div>
  )
}

Feedback

If you find a bug or a flaw in the code, please email me: id_1.0@mail.ru.

Thanks you!

License

MIT © BEISER901


This hook is created using create-react-hook.

privatehas-ownponyfilljoistreams2eslint-pluginmrubootstrap lesstypestasktoobjectperformanceslicebannerbreaklimitformsstyleguidebrowserlistlook-updescriptorcall-bindJSON-SchemalogendpointSymbolimmutableio-tspreserve-symlinksMicrosoftflagssortedworkspace:*robustlinewrapUnderscorekinesisECMAScript 3throttleconcatMapemitpathreadcryptduplexpropertysafeexpresspackagelessiamsymbolscryptoECMAScript 7ECMAScript 2021efficientdiffrfc4122css nestingsearchspinnerawaitaccessibilityairbnbcolumnavaArray.prototype.includesfile systemObject.entrieses6es2016.envmatchrapiddescriptionproprandompicomatchwordbreakobjectArrayBuffer#slicewatchinges8bundlinghttpsdatesequencereduceragentdirectoryMapwalkoutputi18ntrimRightBigInt64Arrayreactpreprocessor[[Prototype]]findupelasticacheES2018getterclassnamessqsES5copyvalueprotoconsoleequalityonceastconfigurableruntimesetPrototypeOftrimEndregular expressionparentsequalprogresscollectiontextcolorfullwidthcolumnsRFC-6455forEachviewfastlookgetoptinternalebslimitedbundleriteratordayjsutilitylockfileshellstylesheettesterroutinglanguagedatamodulewhatwgPromisedynamodbchromiumRegExp#flagsfluxoffsetthroat$.extendasciideterministicrateObject.isauthenticationfast-deep-copyconcurrencyinvariantsymlinkssomeBigUint64ArraysnstestSettostringtagshrinkwrapguideveryenumerableregulargroupsyntaxerrortouchWebSocketbyteJSONdeepcloneECMAScript 6connectbindwalkingECMAScript 2020tsliba11ycircularfunctionString.prototype.matchAllglobtoSortedrgbreadableless cssfind-upxtermstarterObject.definePropertyObjectremoverm -fres-shim APIfunctionsnamestypedarrayfastifylibphonenumberkarmamatchAllnodejsoptionECMAScript 5lastentriescharactersstructuredCloneregular expressionsprotobufs3postcssgradients css3bcryptelectronECMAScript 2023mkdirpvestObject.valuesexecmatchesfast-clonepersistentredact256fastclonemkdirdatastructurecall-boundlivehasOwnframeworkbuffersfindLastpackagesgdprcachecode pointscloudsearchcorsidcharacterpropertiestyped arrayfixed-widthES6fileasyncStreamfast-deep-cloneeslintworkerless.jsTypeScriptes5
1.0.0

1 year ago