react-withcontainer
HOC that allows ioc for Uis to wrap themselves in containers passing themselves to the container as props.container.
Installation
Install with npm:
npm install react-withcontainer
Or with yarn:
yarn add react-withcontainer
Usage
Container
Your container should contain all the normal logic for containers under the container-presenter pattern, and should expect to receive an additional field component represeting the Prenter Component in its props as props.component.
// ExampleContainer.tsx;; /** * This is the props for the container. */ /** * These are the props the container will pass on to its Presenter/Ui. */ ;
Presenter
Your presenter accepts all the props passed by the component and should focus only on providing a Ui. It can then use the withContainer() HOC to wrap itself in an appropriate compatable container.
// ExampleUi.tsx;;;; // This contains the example component from above. ; ;
Typescript
This project is written in typescript and comes with its own bindings.
License
Licensed under the MIT license.