Skip to content

Instantly share code, notes, and snippets.

@goofmint
Created June 7, 2017 01:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goofmint/15abd970a7547c4aac4f1c478c8360c5 to your computer and use it in GitHub Desktop.
Save goofmint/15abd970a7547c4aac4f1c478c8360c5 to your computer and use it in GitHub Desktop.
/** @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