Last active
June 29, 2018 06:31
-
-
Save eyaleizenberg/33025b118c6c155a4fa7d3e215a57c6b to your computer and use it in GitHub Desktop.
state in constructor
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
interface IProps { | |
superhero: string; | |
} | |
interface IState { | |
health: number; | |
} | |
export class MyComponent extends React.PureComponent<IProps, IState> { | |
constructor(props: IProps) { | |
super(props); | |
this.state = { health: 100 }; | |
} | |
render() { | |
return <span>{`${this.props.superhero} health is: ${this.state.health}`}</span> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment