Skip to main content

useGlobal

Callable

  • useGlobal<Value>(key, initialValue): Value

  • Return a new global value from globalStorage if not previously set. This is handful when using hot module reload.

    const myModuleState = useGlobal('@my-org/my-module', () => ({ foo: true }));
    const mySymbolState = useGlobal(Symbol.for('@my-org/my-module'), () => ({ bar: true }));