react-redux-toolkit
v0.0.1-alpha.2
Published
This library implements connection of **React, React-Router, Redux, RxJS**. It really speeds up developing simple SPA.
Downloads
235
Readme
This library implements connection of React, React-Router, Redux, RxJS. It really speeds up developing simple SPA.
react-redux-toolkit does:
- Handling REST API requests.
- Parsing data from response to redux store and easily passing it to your component.
- Handling authorization, user permissions checking.
- And others.
Example of usage
File routes.js:
const routes = [
{
path: '/user-list',
component: UserList,
initialRequest: {
dataListID: 'users',
dataListURL: '/users',
defaultParams: {
_limit: 100,
_sort: 'name'
},
transformResponse: (body) => ({
total: body.total,
data: body.list
})
},
allowedRoleTypes: ['admin', 'super-admin'],
modalWindows: [
{
modalID: 'editCreateUsers',
component: EditCreateUsers,
reqObj: (data) => (data.id
? { method: 'put', url: `/../users/${data.id}/`, data }
: { method: 'post', url: '/../users/', data }),
dataListID: 'users'
}
]
},
...
];
export default routes;
File UserList.js:
const UserList = ({ data }) => (
{/* Here render your users (for example) */}
{data.map(user => (
<div>{user.name}</div>
<div>{user.email}</div>
))
)
File App.js:
import { Routes } from 'react-redux-toolkit';
import myRoutes from './routes';
const App = () => (
<Routes routes={myRoutes}>
);