Skip to content

Instantly share code, notes, and snippets.

@indreklasn
Created September 7, 2020 13:54
Show Gist options
  • Save indreklasn/78c500d224731250d5291421154247fa to your computer and use it in GitHub Desktop.
Save indreklasn/78c500d224731250d5291421154247fa to your computer and use it in GitHub Desktop.
type MyProps = {
// using `interface` is also ok
message: string;
};
type MyState = {
count: number; // like this
};
class App extends React.Component<MyProps, MyState> {
state: MyState = {
// optional second annotation for better type inference
count: 0,
};
render() {
return (
<div>
{this.props.message} {this.state.count}
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment