Provider

information

By default, the export package name for all APIs in this section is: @modern-js/runtime/model.

If Reduck is integrated separately from Modern.js, the export package name is: @modern-js-reduck/react.

Provider is a component that injects Reduck's Store into the application's component tree, making the Model accessible to components inside the component tree. Normally, Provider is defined at the top level of the component tree.

Function Signature

interface ProviderProps {
  store?: ReduckStore;
  config?: AppConfig;
}

Input

  • store: the Store object created by createStore.
  • config: this config to create Reduck Store, same as config param in createApp.

Example

App entry file
ReactDOM.render(
  <Provider>
    <App />
  </Provider>,
  document.getElementById('root'),
);