A data provider is a wrapper component that exposes application data or state-management capabilities to descendant components. It separates the presentation layer from the data layer while keeping the application component as architectural glue. section 8.2 section 8.7.2
A practical data-provider boundary typically handles:
- Restoring persisted state before initializing the underlying state machine. section 8.7.2
- Subscribing to state changes and persisting the complete machine state, including context. section 8.7.2
- Exposing focused hooks for selectors, commands, collection access, and current-item access instead of coupling presentation components to the machine directly. section 8.2
XState-backed data provider
A slim DataProvider reads a saved state or machine.initialState, creates a service with useInterpret, subscribes to service changes, and renders DataContext.Provider around its children. Consumer hooks then select state or send events such as ADD, SEE, and DO_THAT.
