3 ms·
at my last job we did a gradual migration from Angular 1 to React. Its similar to the path to Angular 2 really. React and Angular can live side by side... All w
by shados 10y ago
at my last job we did a gradual migration from Angular 1 to React. Its similar to the path to Angular 2 really. React and Angular can live side by side... All we did was build an Angular directive that can render a react component in a subtree (that's easy), and a React component that could render an Angular directive (that's a little harder, but not that bad).
With that, we could put a React component anywhere in our Angular app, and reuse Angular directives inside of React until we got around to rewriting them.
That ended up quite smooth.
- tomasduda 10y agoWould you mind sharing the code for this?
- shados 10y agoI wanted to open source it at the time...then my employer had layoffs :) The "React component inside of Angular directive" is fairly trivial and there's a million examples on the net. Just make a directive that calls ReactDOM.render on the element in the link function. Angular inside of a React component is harder to google for, namely because there's so much misinformation saying its impossible. It ended up being a variation of the discussion here: https://github.com/ngReact/ngReact/issues/80 https://github.com/ngReact/ngReact/issues/80 (The code in the example isn't quite there...and its been a very long time since I did it, so I don't quite remember the tweaks I had to make).