Skip to content

Instantly share code, notes, and snippets.

@eyaleizenberg
Last active June 29, 2018 06:31
Show Gist options
  • Save eyaleizenberg/33025b118c6c155a4fa7d3e215a57c6b to your computer and use it in GitHub Desktop.
Save eyaleizenberg/33025b118c6c155a4fa7d3e215a57c6b to your computer and use it in GitHub Desktop.
state in constructor
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