For the cases when we want to rerender a component with given props
accepts
React component
returns
Enhanced React Component with a static method `feed`
import{feed}from'hocbox';
// We pass a React Component to feed
constComponent=feed(function({ answer }){
return<p>The answer is { answer ||'...'}</p>;
});
// ... and we render our Component
classAppextendsReact.Component{
render(){
return<div><Component /></div>;
}
}
// Then later we rerender with given props
Service('/api/get/the/answer').then(data=>{
Component.feed({ answer: data });
});
Service in the example above is just a HTTP layer that fetches data from let's say API.
Dependency injection
Provide anything to any React component of your application. The dependencies are registered at the very top layer and via the wire method they may reach your components.