Prop drilling through 3+ component layers (use a local store instead)
Subscribing to state only used in callbacks (read on-demand)
Local vs Global State
Keep local UI state in leaf components:Lift state when multiple components need it:When to use a local store:
State needed across many components (theme, user, org)
State should persist across navigation
Bundle-wide configuration
Local Stores
Use createLocalStore from @prepared911/core/stores/local for state one bundle (one remote or one shell) owns. Call it once at module scope. It generates a reactive hook and a getter per state key, and useStore for any other selector.With selectors:The core-stores skill is the rule for this call.
Avoiding Prop Drilling
Don't pass props through 3+ component layers:When prop drilling is acceptable:
Props passed through 1-2 levels
Props specific to a feature/component tree
Props don't change frequently
Optimization Patterns
Defer State Reads
Don't subscribe to state only used in callbacks—read on-demand:
Lazy State Initialization
Pass a function to useState for expensive initial values:Use lazy initialization for: