(value: T | IFuncUpdater<T>)
| 65 | }, [key]); |
| 66 | |
| 67 | const updateState = (value: T | IFuncUpdater<T>) => { |
| 68 | const currentState = _isFunction(value) ? value(state) : value; |
| 69 | setState(currentState); |
| 70 | |
| 71 | if (_isUndefined(currentState)) { |
| 72 | storage?.removeItem(key); |
| 73 | } else { |
| 74 | try { |
| 75 | storage?.setItem(key, serializer(currentState)); |
| 76 | } catch (e) { |
| 77 | console.error(e); |
| 78 | } |
| 79 | } |
| 80 | }; |
| 81 | |
| 82 | return [state, useMemoizedFn(updateState)] as const; |
| 83 | } |
nothing calls this directly
no test coverage detected