Docs

Errors Explained

A guide to the common debugging warnings and strictly-typed development errors emitted by react-use-superstate.

1. Key Not Initialized

Error: [super-state] Key "user" not initialized. Use createSuperState first.

Why it happens: You tried consuming a state via useSuperState('user') before it was ever declared globally. React-Use-Superstate requires one component in the tree to claim "ownership" of the state object exactly once.

How to fix it:

// Initialize it in a higher-level or root component:
const [user, setUser] = createSuperState('user', { name: "Guest" });

2. Duplicate Initialization Warning

Warning: [super-state] Duplicate initialization of key "user"...

Why it happens: You called createSuperState('user') multiple times in your application, which leads to initial-value conflicts as components race to inject their default value.

How to fix it: Only use createSuperState once per key (usually context or root level), and use useSuperState everywhere else passing only the key.

3. Suspicious Dot-Notation Key

Warning: [super-state] Suspicious key "user..name": avoid consecutive dots.

Why it happens: You provided a malformed string constraint with missing paths or hanging identifiers (like .user. or user..name). SuperState will aggressively warn you in development mode so that nested tree mutation caches safely target proper sub-paths.