MCPcopy Create free account
hub / github.com/msgbyte/tailchat / updateState

Function updateState

client/shared/hooks/factory/createUseStorageState.ts:67–80  ·  view source on GitHub ↗
(value: T | IFuncUpdater<T>)

Source from the content-addressed store, hash-verified

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 }

Callers

nothing calls this directly

Calls 2

serializerFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected