-
-
Save ypcode/a2edcc6c6ed82aa4cd6a4559ca063cdb to your computer and use it in GitHub Desktop.
This file contains 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 styles from './HelloWorld.module.scss'; | |
import { IHelloWorldProps } from './IHelloWorldProps'; | |
import { IGreetingsService, GreetingsServiceKey } from '../../../services/GreetingsService'; | |
import { inject } from '../../../di/DependenciesManager'; | |
export default class HelloWorld extends React.Component<IHelloWorldProps, {}> { | |
// We declare a field that will be injected with the GreetingsService registered instance | |
@inject(GreetingsServiceKey) private greetingsService: IGreetingsService; | |
public render(): React.ReactElement<IHelloWorldProps> { | |
let hello = this.greetingsService.sayHello('Yannick'); | |
return ( | |
<div className={styles.helloWorld}> | |
<div className={styles.container}> | |
<div className={styles.row}> | |
<div className={styles.column}> | |
<span className={styles.title}>Welcome to Dependency Injection!</span> | |
<p>{this.props.description}</p> | |
<p className={styles.subTitle}> | |
Result from service: {hello}. | |
</p> | |
</div> | |
</div> | |
</div> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment