feathersjs-ecosystem / feathers-redux

Integrate Feathers with your Redux store
MIT License
114 stars 23 forks source link

Error with ON_CREATED & co. reducers, when queryResult is null #42

Closed erkkaha closed 6 years ago

erkkaha commented 6 years ago

https://github.com/feathers-plus/feathers-redux/blob/cf5b00b8634b34e151ca4473938c5882655de9c1/src/index.js#L244

There is an issue with ON_CREATED and other event reducers if query result is null, since there is no null check an error will be thrown if actions are dispatched before anything has been queried. I can make a PR to fix this, but I was wondering is what is the reason why initial state has queryResult: null? As this could be fixed by either checking if queryResult exists or adding initial state with empty data and total:0.

eddyystop commented 6 years ago

I will look into this when I return from vacation next Wednesday.

bsubedi26 commented 6 years ago

@erkkaha, Good catch. I didn't have this issue because services.find() (which replaces the queryResult from null to proper structure) was executed before the ON_CREATED. I think structuring the queryResult initial state would be a better approach rather than checking if queryResult is null within the reducer switch case statement.

markchkhotua commented 6 years ago

Have the same result. Can it be fixed in next few days?

eddyystop commented 6 years ago

Reportedly fixed in https://github.com/feathers-plus/feathers-redux/pull/43

eddyystop commented 6 years ago

Published as 2.1.0