@@ -40,15 +40,6 @@ function throttle(cb, ms) {
40
40
} ;
41
41
}
42
42
43
- function getEnvironment ( ) {
44
- const isDOM =
45
- typeof window !== "undefined" &&
46
- window . document &&
47
- window . document . documentElement ;
48
-
49
- return isDOM ? "browser" : "server" ;
50
- }
51
-
52
43
export function useBattery ( ) {
53
44
const [ state , setState ] = React . useState ( {
54
45
supported : true ,
@@ -1373,40 +1364,6 @@ export function useRenderInfo(name = "Unknown") {
1373
1364
}
1374
1365
}
1375
1366
1376
- export function useSessionStorage ( key , initialValue ) {
1377
- if ( getEnvironment ( ) === "server" ) {
1378
- throw Error ( "useSessionStorage is a client-side only hook." ) ;
1379
- }
1380
-
1381
- const readValue = React . useCallback ( ( ) => {
1382
- try {
1383
- const item = window . sessionStorage . getItem ( key ) ;
1384
- return item ? JSON . parse ( item ) : initialValue ;
1385
- } catch ( error ) {
1386
- console . warn ( error ) ;
1387
- return initialValue ;
1388
- }
1389
- } , [ key , initialValue ] ) ;
1390
-
1391
- const [ localState , setLocalState ] = React . useState ( readValue ) ;
1392
-
1393
- const handleSetState = React . useCallback (
1394
- ( value ) => {
1395
- try {
1396
- const nextState =
1397
- typeof value === "function" ? value ( localState ) : value ;
1398
- window . sessionStorage . setItem ( key , JSON . stringify ( nextState ) ) ;
1399
- setLocalState ( nextState ) ;
1400
- } catch ( e ) {
1401
- console . warn ( e ) ;
1402
- }
1403
- } ,
1404
- [ key , localState ]
1405
- ) ;
1406
-
1407
- return [ localState , handleSetState ] ;
1408
- }
1409
-
1410
1367
export function useScript ( src , options = { } ) {
1411
1368
const [ status , setStatus ] = React . useState ( ( ) => {
1412
1369
if ( ! src ) {
0 commit comments