Skip to content

Instantly share code, notes, and snippets.

@ufukcanli ufukcanli/context.js
Last active May 9, 2019

Embed
What would you like to do?
Passing event listener
export class Provider extends Component {
state = {
name: 'Ufuk',
age: 22,
};
incrementAge = () => {
this.setState({
age: this.state.age + 1
})
};
render() {
return (
<Context.Provider value={{
state: this.state,
incrementAge: this.incrementAge
}}>
{this.props.children}
</Context.Provider>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.