Created
August 25, 2018 13:54
-
-
Save tswistak/c401037e6aa1733629278a12f21e38ad to your computer and use it in GitHub Desktop.
InversifyJS with React, listing 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as React from "react"; | |
| import { resolve } from "inversify-react"; | |
| import { IProvider } from "./providers"; | |
| export class Hello extends React.Component { | |
| @resolve("nameProvider") private readonly nameProvider: IProvider<string>; | |
| render() { | |
| return <h1>Hello {this.nameProvider.provide()}!</h1>; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import "reflect-metadata"; | |
| import * as React from "react"; | |
| import { render } from "react-dom"; | |
| import { Provider } from "inversify-react"; | |
| import { Hello } from "./Hello"; | |
| import { container } from "./ioc"; | |
| const App = () => ( | |
| <Provider container={container}> | |
| <div> | |
| <Hello /> | |
| </div> | |
| </Provider> | |
| ); | |
| render(<App />, document.getElementById("root")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment