createStoreHook<TReduxState> function

Store<TReduxState> Function() createStoreHook<TReduxState>([
  1. Context? context
])

Returns a function that can be named and used as a replacement for useStore when you want to use custom context.

This is useful if you're building a complex reusable component, and you don't want your Store to collide with any Redux Store your consumers' applications might use.

This should probably not be used frequently. Prefer createSelectorHook as your primary choice. However, this may be useful for less common scenarios that do require access to the Store, such as replacing reducers. Using this hook will not result in the component updating when store values change!

See the react-redux JS documentation for more details.

See the createSelectorHook documentation for an example of creating / using custom context.

Implementation

Store<TReduxState> Function() createStoreHook<TReduxState>([Context? context]) {
  final jsHook = _jsCreateStoreHook(context?.jsThis ?? JsReactRedux.ReactReduxContext);
  Store<TReduxState> dartHook() => jsHook().dartStore as Store<TReduxState>;

  return dartHook;
}