简体   繁体   English

如何合并AngularJS,React和Redux?

[英]How can I merge AngularJS , React and Redux?

I am building an application using angular and redux (ngRedux). 我正在使用angular和redux(ngRedux)构建应用程序。 Now i want to use react instead of angular for improvement in performance. 现在,我想使用react而不是angular来提高性能。 It is a huge application so it is not possible to build it from scratch. 这是一个巨大的应用程序,因此不可能从头开始构建它。 So i want to use the routing of angularJS (angular-ui-router) and as any "abc" state become active then the react component become load and this react component should use the pure redux against every single event. 所以我想使用angularJS(angular-ui-router)的路由,并且当任何“ abc”状态变为活动状态时,react组件将变为负载,并且此react组件应针对每个事件使用纯redux。

How can i maintain my application accordingly that a single module is build in react-redux and connected to angular only through routing state. 我该如何相应地维护我的应用程序,即在react-redux中构建单个模块,并仅通过路由状态将其连接到angular。 Keep in mind that the other modules of application should also not be disturbed. 请记住,应用程序的其他模块也不应受到干扰。

Well to render React components into Angular is quite easy. 将React组件渲染到Angular中非常容易。 But I just assume you use directive or component from angular already. 但是我只是假设您已经从角度使用了directivecomponent

So in the case of directive you could skip the whole templating "none sense" and let React handle that for you 因此,在使用directive的情况下,您可以跳过整个模板“无意义”,然后让React为您处理

module.directive("reactTest",function() {
  return {
    link:function(scope,element,attr) {
      class App extends React.Component {
        constructor(props) { super(props) }

        render <div></div>
      }
      element.replace(App);

    }
  }
});

So this how you would get React into Angular. 因此,这就是将React引入Angular的方式。 Redux ist basically the same. Redux ist基本相同。 You simple use the connect function of redux and off you go. 您只需使用redux的connect功能即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM