prevData is undefined when passed to transformer
jakeaaron opened this issue · 4 comments
I have an api reducer as such:
export default combineReducers({
plans: combineReducers(plansAPI.reducers),
users,
search,
friends,
readingPlans,
})
where plansAPI is the redux-api endpoint
and then I'm importing that into the main reducer.
can you explain how this library expects the state shape to be?
and how to be able to change the state shape?
My prevData is undefined in my plansAPI tranformers.
Can't we have our reducer combined and nested deeper than the root level? How can we have multiple reducers alongside this one?
Thanks for the help.
Hi. You can see example in test https://github.com/lexich/redux-api/blob/master/test/redux_spec.js#L321-L344
If you use alias for redux-api, you should use prefix option
Hello, @lexich!
Thanks so much for the response.
So this library is expecting a key in state that matches the prefix key at the top level?
For instance:
const rest2 = reduxApi({
test: "/test2"
}, { prefix: "r2" }).use("fetch", fetch);
const reducer = combineReducers({
r2: combineReducers(rest2.reducers)
});
this means that it is state.r2 right?
is there a way to do something like this?
const rest2 = reduxApi({
test: "/test2"
}, { prefix: "r2" }).use("fetch", fetch);
export const reducer = combineReducers({
r2: combineReducers(rest2.reducers)
});
..........
// some different main reducer file
import { reducer } from './restAPI'
export combined reducer = combineReducers({
rest: reducer,
somethingElse: () => { return null },
})
where the restAPI prefix is nested under state.rest.r2 instead of state.r2?
Thanks for your help
@jakeaaron unfortunately at this moment it's not possible. But I think that it's not critical improvement.
https://github.com/lexich/redux-api/blob/master/src/actionFn.js#L64