redux-blackbox
Reduce redux boilerplate by following conventions
How to use
setup reducer
// reducer/index.js ; users:
setup actions
// actions/users.js; const fetchUsers = { return axios;} const fetchUsersAction = { return async { return await actions; }}
setup component
// components/ListUsers.jsimport IN_PROGRESS FAILED SUCCESS from "redux-blackbox/constants"; const ListUsers = users if usersuiState === IN_PROGRESS return <div>Loading...</div> if usersuiState === FAILED return <div ="notification is-danger">userserrormessage</div> if usersuiState === SUCCESS if userslistinglength return <div> <ul> userslisting </ul> </div> else return <div>Users list is empty</div> return null; const mapStateToProps = state return users: stateusers const mapDispatchToProps = fetchUsersAction mapStateToProps mapDispatchToPropsListUsers;
License
Please see License