Created
June 7, 2017 01:31
-
-
Save goofmint/15abd970a7547c4aac4f1c478c8360c5 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
/** @jsx element */ | |
import {element, createApp} from 'deku' | |
import {createStore} from 'redux' | |
import reducer from './reducer' | |
// Dispatch an action when the button is clicked | |
let log = dispatch => event => { | |
dispatch({ | |
type: 'CLICKED' | |
}) | |
} | |
// Define a state-less component | |
let MyButton = { | |
render: ({ props, children, dispatch }) => { | |
return <button onClick={log(dispatch)}>{children}</button> | |
} | |
} | |
// Create a Redux store to handle all UI actions and side-effects | |
let store = createStore(reducer) | |
// Create an app that can turn vnodes into real DOM elements | |
let render = createApp(document.body, store.dispatch) | |
// Update the page and add redux state to the context | |
render( | |
<MyButton>Hello World!</MyButton>, | |
store.getState() | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment