Created
September 7, 2020 13:54
-
-
Save indreklasn/78c500d224731250d5291421154247fa to your computer and use it in GitHub Desktop.
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
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