Closed oskarer closed 8 years ago
redux-await is meant to be used with plain objects. In order to make it work with any other store type we would need to wrap the reducer state and either require the container to either use connect
from redux-await
, or get props from a custom function
Either
-- import { connect } from 'react-redux';
++ import { connect } from 'redux-await';
@connect(state => state)
class App extends Component {
}
or this:
++ import { getProps } from 'redux-await';
render() {
-- const { dispatch, users } = this.props;
++ const { dispatch } = this.props;
++ const { users } = getProps(this.props)
}
I was able to make a very dirty fix to get it to run with Immutable.js Maps, which obviously doesn't work with plain javascript objects. What do you think of this approach? Could redux-await be modified to handle both Immutable.js and plain javascript objects?
If it works for your use case, then fork it and use that. My plan is to use a custom connect
er similar to what redux-form
does, something like this
export const function connect(mapStateToProps, ...rest) {
return reduxConnect(state => {
const props = mapStateToProps(state);
const { statuses, errors } = state.await;
return { ...props, statuses, errors };
}, ...rest);
}
and also require control over a branch of the tree like most other higher order redux modules:
const reducers = combineReducers({
todos: todosReducer,
await: awaitReducer,
})
expect a v5 sometime soon
BTW to use your fork, you would need to remove the lib/
entry from your package.json, run npm run build
then commit that then npm install oskarer/redux-await
on your consumer project
Alright, thanks! Closing this issue then.
@oskarer Just pushed 5.0.0
, it should solve the issue you were having
I'm trying to use redux-await with Immutable.js, however it does not seem to work. The following was my code before trying Immutable.js, which works fine:
However trying the same thing with Immutable generates an error, saying that "undefined is not a function". Cannot figure out exactly where that is tho.
Is redux-await suppose to work with Immutable.js or is it a limitation it has?