Created
July 24, 2021 01:59
-
-
Save MeetMartin/d59aea5fa7dd01d528e950bfa0b48b85 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
| import React, { useContext } from 'react'; | |
| import { StoreContext } from '../store/StoreContext'; | |
| const MyComponent = () => { | |
| const { state, actions } = useContext(StoreContext); | |
| const myAction = () => actions.triggerAction('data'); | |
| return( | |
| <> | |
| Number of button clicks: {state.counter}. | |
| <button onClick={myAction}>Click me</button> | |
| </> | |
| ) | |
| }; | |
| export default MyComponent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment