Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Redux store to render. #58

Closed
evgeny-s opened this issue Dec 27, 2017 · 2 comments
Closed

Add Redux store to render. #58

evgeny-s opened this issue Dec 27, 2017 · 2 comments
Assignees
Labels

Comments

@evgeny-s
Copy link

Hello.
Is it possible somehow to add Redux Store configuration, to be able to use this library with Redux?
Thank you.

@bcherny
Copy link
Contributor

bcherny commented Dec 27, 2017

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.

@bcherny bcherny closed this as completed Dec 27, 2017
@bcherny bcherny self-assigned this Dec 27, 2017
@evgeny-s
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants