Skip to content

Instantly share code, notes, and snippets.

@mattapperson
Created July 12, 2015 00:52
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 mattapperson/db45538f14d6de52f6ad to your computer and use it in GitHub Desktop.
Save mattapperson/db45538f14d6de52f6ad to your computer and use it in GitHub Desktop.
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>
);
}
}
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