Add Redux store to render.
evgeny-s opened this issue · 2 comments
evgeny-s commented
Hello.
Is it possible somehow to add Redux Store configuration, to be able to use this library with Redux?
Thank you.
bcherny commented
Hi @evgeny-s! Have you tried simply wrapping your presentational component with react2angular?
Without seeing your code, it would look something like this:
let mapStateToProps = (state, ownProps) => ...
let mapDispatchToProps = (dispatch, ownProps) => ...
let FooWithRedux = connect(
mapStateToProps,
mapDispatchToProps
)(Foo)
let FooWithAngular = react2angular(FooWithRedux)
Please let me know if that works for you, or if you run into any issues.
evgeny-s commented
The problem that we havn't Redux Provider wrapper in case of using components from Angular.
I've added store manually like this:
export const connectWithStore = (WrappedComponent, ...args) => {
const ConnectedWrappedComponent = connect(...args)(WrappedComponent);
const store = configureStore({});
return (props) => (
<ConnectedWrappedComponent {...props} store={store}/>
);
};
And now I using this connect function with store connected manually, since we can't wrap everything with
<Provider store={store}></Provider>
I've found this solution here:
reduxjs/react-redux#390