import * as React from 'react' ; const { useState } = React ; type Session = ( value : any ) => void ; function useSessionStorage ( key , initialValue ? ) { const [ value , setValue ] = useState ( ( ) => { try { const cacheValue = window . sessionStorage . getItem ( key ) ; return cacheValue ? JSON . parse ( cacheValue ) : initialValue ; } catch ( error ) { return initialValue ; } } ) ; const setSession = ( value ) => { setValue ( value ) ; window . sessionStorage . setItem ( key , JSON . stringify ( value ) ) ; } ; return [ value , setSession ] ; } export default useSessionStorage ;