1.0.1 • Published 7 years ago
@salsita/react-crud v1.0.1
react-crud
Install
Install this package with npm
npm i @salsita/react-crudor yarn
yarn add @salsita/react-crudAPI
Modules
Constants
Functions
CrudActions
CrudActions.entitiesFetched(route, key, result) ⇒ Action
Saves result of normalized data for a route
Kind: static method of CrudActions
| Param | Type | Description |
|---|---|---|
| route | string | Route name |
| key | string | Key of entity |
| result | number | Array.<number> | ID or IDs of entities (the result of normalization) |
withRouterParams ⇒ function
Creates a composed effectParamsFactory which automatically passes current route params to effectParamsFactory
Kind: global constant
Returns: function - Composed effectParamsFactory
| Param | Type | Description |
|---|---|---|
| effectParamsFactory | function | to be wrapped |
crudReducer(state, action) ⇒ CrudState
The reducer of the crud module
Kind: global function
| Param | Type | Description |
|---|---|---|
| state | CrudState | The state of the crud module |
| action | Action | A redux action |
saveEntity(entityData, entity, mapEntityToSaveParams, form) ⇒ Object
Creates or updates entity from form data
After entity has been saved, it reflects the data back into entity repository.
Kind: global function
Returns: Object - updated entity
| Param | Type | Description |
|---|---|---|
| entityData | Object | Entity data |
| entity | string | Entity type |
| mapEntityToSaveParams | function | A function that maps an entity to the save params |
| form | string | Id of the form |
crudSaga(mapRouteToFetchParams)
This saga has to be forked in the root saga of the app
Kind: global function
| Param | Type | Description |
|---|---|---|
| mapRouteToFetchParams | function | A function that maps a route to the fetch params |