Skip to content

Instantly share code, notes, and snippets.

@MeetMartin
Created July 24, 2021 01:59
Show Gist options
  • Select an option

  • Save MeetMartin/d59aea5fa7dd01d528e950bfa0b48b85 to your computer and use it in GitHub Desktop.

Select an option

Save MeetMartin/d59aea5fa7dd01d528e950bfa0b48b85 to your computer and use it in GitHub Desktop.
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