Last active
January 10, 2020 13:50
-
-
Save hosseinmd/4e29cb74e5d506dad130c50daea7271b to your computer and use it in GitHub Desktop.
This file contains 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 from "react"; | |
import { Store } from "./store"; | |
import Count from "./Count"; | |
//don't connect to store | |
const App = () => { | |
const {actions} = Store | |
return ( | |
<div> | |
<Count /> | |
<button | |
type="button" | |
onClick={() => actions.increase()} | |
> | |
+1 to counter | |
</button> | |
<button | |
type="button" | |
onClick={() => actions.decrease()} | |
> | |
-1 to counter | |
</button> | |
</div> | |
); | |
}; | |
export default App |
This file contains 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 from "react"; | |
import { useGlobal } from "./store"; | |
// connected to store | |
const Count = () => { | |
const [state, actions] = useGlobal(["counter"]); | |
return ( | |
<p> | |
counter: | |
{state.counter} | |
</p> | |
); | |
}; | |
export default Count; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment