Versent / redux-crud

A set of standard actions and reducers for Redux CRUD Applications
MIT License
624 stars 54 forks source link

Custom key doesn't work with create or update, only with fetch #56

Closed GuillaumeJasmin closed 7 years ago

GuillaumeJasmin commented 7 years ago

I use a custom key "uuid" instead of "id", like this: reduxCrud.List.reducersFor('permissions', {key: 'uuid'});

It works with fetchSuccess(data), but I get this error when I want to update with updateSuccess(data), or create with createSuccess(data): Uncaught (in promise) Error: Expected record.id in updateSuccess

I don't understand, because my data has a "uuid" key.

Maybe the custom key is not implemented into create or update action ?

Thanks

hwaterke commented 7 years ago

You need not only to pass your custom key to the reducersFor function but also to the actionCreatorsFor function.

For example:

reduxCrud.actionCreatorsFor(resource.path, {key: 'uuid'});
GuillaumeJasmin commented 7 years ago

Thanks ! This was not specified in doc, so I added it

sporto commented 7 years ago

@hwaterke thanks for answering issues, really appreciate it