Skip to content

Instantly share code, notes, and snippets.

@terrierscript
Last active November 2, 2015 13:25
Show Gist options
  • Save terrierscript/aa53dd94c02e228c8164 to your computer and use it in GitHub Desktop.
Save terrierscript/aa53dd94c02e228c8164 to your computer and use it in GitHub Desktop.
Redux初めて触って色々わかったメモ ref: http://qiita.com/inuscript/items/8dc5af052a858023287f
function mapStateToProps(state) {
return { todos: state.todos };
}
export default connect(mapStateToProps)(TodoApp);
class UsersStore extends Marty.Store {
constructor(options) {
super(options);
this.state = [];
this.handlers = {
addUser: Constants.RECEIVE_USER
};
}
addUser(user) {
this.state.push(user);
this.hasChanged();
}
}
function someReducer(state, action) {
switch (action.type) {
case SOME_ACTION:
return Object.assign({}, state, {
some: action.someValue
});
default:
return state;
}
}
<Provider store={store}>
{() => <App/>}
</Provider>
function someReducer(state, action) {
switch (action.type) {
case SOME_ACTION:
state.someValue = action.someValue
return state;
default:
return state;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment