Internal reusable logic for React injectors.
The same component is exported from @redux-tools/reducers-react
, @redux-tools/epics-react
and @redux-tools/middleware-react
as well.
The <Provider />
React component makes the injection mechanism accessible to nested components. There are essentially three approaches to using this component:
- You do not need to handle namespacing at all.
- Just use react-redux's
<Provider />
. You don't need to use the @redux-tools<Provider />
at all.
- Just use react-redux's
- You are able to access the current namespace using React context from anywhere inside a widget and you are using a single virtual DOM for all widgets.
- You can wrap the entire application in a single
<Provider useNamespace={useNamespace}>
component and you are done!
- You can wrap the entire application in a single
- You are not using a single virtual DOM or you cannot reliably access the namespace from a nested component.
- You should resort to wrapping each widget separately by using
<Provider namespace={namespace}>
instead.
- You should resort to wrapping each widget separately by using
This component is also a drop-in replacement for react-redux's <Provider />
.
store
: The Redux store.- [
useNamespace
] (Function): A function or a hook which returns the correct namespace (probably by using React context). - [
namespace
] (string): A namespace to use for all nested components. Has priority overuseNamespace
. - [
feature
] (string): Feature to set the namespace for. Allows arbitrary nesting.