Last active
December 23, 2019 21:17
-
-
Save marchingband/d9f9f547d61b216931264f3f4a4fec2e 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 {useStore, keys} from './useStore.js' | |
const ColoredTextBox = () => { | |
const [{text, color}, actions] = useStore([keys.text, keys.color]) | |
return( | |
<div | |
style={{backgroundColor:color}} | |
onClick={()=>actions.setColor(color=='red'?'green':'red')} | |
> | |
{text} | |
</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment