3

I have an Angular 4 application, implemented using the redux architecture with this library https://github.com/ngrx/platform. I want to use some custom React components in my app. My guess is that I would have to rewrite my large Angular components into React components, as it would not be possible to embed a custom React library into already existing Angular components. Also, considering that I have not used the framework agnostic redux library, I would need to rewrite that part of my app as well, basically amounting to a whole rewrite. Am I correct in my assessment?

1 Answer 1

6

You can use ReactDOM.render() to render react components inside of your angular components, or alongside them. As for the ngrx issue you can probably implement some middleware or an Angular service that can provide data to your react components. You could even make an Angular component to wrap your react components and pass them props from the ngrx store. You could also use portals in your react components to accomplish a similar goal.

This may not be the most performant solution (rewriting will almost always work better) but if you just want the functionality and the performance cost isn't too bad it should be fairly simple to implement.

Sign up to request clarification or add additional context in comments.

1 Comment

The wrapper idea makes sense, but I believe, as the project grows larger this would be hard to maintain. I will try to make a POC to see how this works. A rewrite makes more sense. Thank you for your answer!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.