Home / Function/ initStoreFromUrlOrLocalStorage() — react Function Reference

initStoreFromUrlOrLocalStorage() — react Function Reference

Architecture documentation for the initStoreFromUrlOrLocalStorage() function in store.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  437c46d4_8fab_c101_3235_3409c9d1c254["initStoreFromUrlOrLocalStorage()"]
  4949445b_a2de_ca5c_8e91_50e8a7ed966a["store.ts"]
  437c46d4_8fab_c101_3235_3409c9d1c254 -->|defined in| 4949445b_a2de_ca5c_8e91_50e8a7ed966a
  c8e0a7cc_62bf_9444_abc0_6b16bfe7e380["decodeStore()"]
  437c46d4_8fab_c101_3235_3409c9d1c254 -->|calls| c8e0a7cc_62bf_9444_abc0_6b16bfe7e380
  2a739178_9890_e1c6_b080_c8a0ce48e4cc["isValidStore()"]
  437c46d4_8fab_c101_3235_3409c9d1c254 -->|calls| 2a739178_9890_e1c6_b080_c8a0ce48e4cc
  style 437c46d4_8fab_c101_3235_3409c9d1c254 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/apps/playground/lib/stores/store.ts lines 56–77

export function initStoreFromUrlOrLocalStorage(): Store {
  const encodedSourceFromUrl = location.hash.slice(1);
  const encodedSourceFromLocal = localStorage.getItem('playgroundStore');
  const encodedSource = encodedSourceFromUrl || encodedSourceFromLocal;

  /**
   * No data in the URL and no data in the localStorage to fallback to.
   * Initialize with the default store.
   */
  if (!encodedSource) return defaultStore;

  const raw: any = decodeStore(encodedSource);

  invariant(isValidStore(raw), 'Invalid Store');

  // Make sure all properties are populated
  return {
    source: raw.source,
    config: 'config' in raw && raw['config'] ? raw.config : defaultConfig,
    showInternals: 'showInternals' in raw ? raw.showInternals : false,
  };
}

Domain

Subdomains

Frequently Asked Questions

What does initStoreFromUrlOrLocalStorage() do?
initStoreFromUrlOrLocalStorage() is a function in the react codebase, defined in compiler/apps/playground/lib/stores/store.ts.
Where is initStoreFromUrlOrLocalStorage() defined?
initStoreFromUrlOrLocalStorage() is defined in compiler/apps/playground/lib/stores/store.ts at line 56.
What does initStoreFromUrlOrLocalStorage() call?
initStoreFromUrlOrLocalStorage() calls 2 function(s): decodeStore, isValidStore.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free