如何在Meteor 1.3应用程序中结合react-redux和react-meteor-data?

tha*_*ndo 3 meteor reactjs react-redux

如何使用state属性react-redux来指定注入的数据react-meteor-data

react组件的结构如下:

  import React from "react";
  import {createContainer} from "meteor/react-meteor-data";
  import {connet} from "react-redux";
  import {Data} from "./data.js"

  class App extends React.Component {
     render() {
        return (
           <div>
              {JSON.stringify(this.props.profile)}
           </div>
        );
     }   
  }
  const mapStateToProps = state => ({
      ID: state.dataId    // ID gets assigned to props here
  });

  export default createContainer(
      () => ({
         profile: Data.findOne({_id: >>>ID<<<})   // ID is needed here
      }), 
      connect(mapStateToProps)(App)
  );
Run Code Online (Sandbox Code Playgroud)

非常感谢!

Pat*_*wis 5

你应该看看React-Komposer,它具有redux和流星跟踪器的功能.

https://github.com/kadirahq/react-komposer

与komposer你将获得两个参数propsonData

props是传递给容器onData的道具,是要发送到组合组件的新道具.

现在将两个系统连接在一起,我不肯定这会起作用或者是最好的解决方案但是我想你可以做这样的事情

connect(mapStateToProps)(composeWithTacker(onPropsChange)(App))