Created
May 2, 2019 10:51
-
-
Save RayLuxembourg/c70a9c03453c2c8e035bd01c8c4afa36 to your computer and use it in GitHub Desktop.
Render Props typescript
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
import * as React from 'react'; | |
interface NameProviderProps { | |
children: (state: NameProviderState) => React.ReactNode; | |
} | |
interface NameProviderState { | |
readonly name: string; | |
} | |
export class NameProvider extends React.Component<NameProviderProps, NameProviderState> { | |
readonly state: NameProviderState = { name: 'Piotr' }; | |
render() { | |
return this.props.children(this.state); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment