react-depints
v0.0.3
Published
Official React bindings for Depints
Downloads
6
Readme
React Depints
Official React bindings for Depints.
Provides dependency injection for React components using React pattern Provider/Consumer. You can know more about it here.
Installation
Requires Depints and React v16.3 or later.
npm install --save react-depints
or
yarn add react-depints
Usage
Add provider as a parent to your root app. Passing as props the injector.
import { bootstrap } from "depints";
import { InjectorProvider } from "react-depints";
const injector = bootstrap(AppModule);
<InjectorProvider injector={injector}>
<AppConnected />
</InjectorProvider>
Connect the component you want to inject services in.
class App extends React.Component<AppProps> {
public render() {
return <p>{this.props.logger.log("App", "IT WORKS")}</p>;
return null;
}
}
export const AppConnected = connectInjector({
logger: Logger,
})(App);
Please check examples for more details.