-
-
Save mattapperson/db45538f14d6de52f6ad 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 TodoApp from './TodoApp'; | |
import { createRedux, bindActionCreators } from 'redux'; | |
import { Provider } from 'redux/react'; | |
import AccountActions from '../actions/AccountActions'; | |
import TodoActions from '../actions/TodoActions'; | |
const redux = createRedux(stores); | |
export default class App { | |
getChildContext() { | |
return { | |
actions: { | |
account: bindActionCreators(AccountActions, redux.dispatch) | |
todo: bindActionCreators(TodoActions, redux.dispatch) | |
} | |
} | |
} | |
render() { | |
return ( | |
<Provider redux={redux}> | |
{() => <TodoApp />} | |
</Provider> | |
); | |
} | |
} |
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, { PropTypes } from 'react'; | |
import TodoTextInput from './TodoTextInput'; | |
export default class Header { | |
contextTypes: { | |
actions: React.PropTypes.object.isRequired, | |
} | |
handleSave(text) { | |
if (text.length !== 0) { | |
this.context.todo.addTodo(text); | |
} | |
} | |
render() { | |
return ( | |
<header className='header'> | |
<h1>todos</h1> | |
<TodoTextInput newTodo={true} | |
onSave={::this.handleSave} | |
placeholder='What needs to be done?' /> | |
</header> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment