Aller au contenu principal

useShadowStorageGetter

Callable

  • useShadowStorageGetter(hostObject): <Value>(key, initialValue) => Value

  • Return a new value from the shadow storage of hostObject if not previously set. This is handful when using hot module reload.

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