1.0.3 • Published 5 years ago

auto-react-redux v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

auto-react-redux

Override some react-redux functions to auto-generate, connect, dispatch store, state ...

- No more actions, actions creator, just use the direct name of reducer
- No more: action, type ... just create a reducer with first param: state, followed by other args
- No more dispatch, no more mapStateToProps ... just use listen for re-render when state changed
- Full compatible with React-redux so we can use Redux debug tool for debugging

Example of usage:

import {createAutoReduxStore} from "./auto-redux";

let todoReducers = {
  addTodo: (state, todo) => [...state, todo]
}


let appStore = {
  todos: {reducers: todoReducers, default: []},
};

const $store = createAutoReduxStore(appStore);

class Todo extends React.Component {
  render() {
      return <button onClick={$store.addTodo('New task')}>
          {$store.todos.map(todo => <div>{todo}</div>)}
      </button>
  }
}

export default listen(todos)(Todo);