Open ChrisFan opened 8 years ago
有两个组件:分别为 DataFlowPanel\ModelGroup,项目是一个 dva project
DataFlowPanel 与 ModelGroup 关系
<DataFlowPaper connections={connections} onActiveNodesChange={this.onActiveNodesChange} > <StateGroup coordinates={coordinates.state} /> <ModelGroup coordinates={coordinates.model} models={models.data} /> <ComponentGroup coordinates={coordinates.component} components={routeComponents} /> </DataFlowPaper>
DataFlowPaper 具体实现:
drawPaper() { if (!this.Paper) { this.Paper = createContainer({ width: 1000, height: 1000, })(Paper); } return this.Paper; } ... const DataFlowPaper = this.drawPaper();
ModelGroup 实现:
class ModelGroup extends React.Component { drawLabel() { const { coordinates } = this.props; if (!this.label) { this.label = createNode( () => ({ getNodeData: () => ({ id: 'ModelGroup.Label', x: coordinates.x, y: coordinates.y, }), canDrag: () => false, canSelect: () => false, }) )(Label); } return this.label; } drawModelList() { const { coordinates, models } = this.props; return models.map((m, i) => { const data = { id: m.id, x: coordinates.x, y: coordinates.y + 36 + i * 35, }; return ( <ModelNode key={m.id} data={data} showActionFlow={this.showActionFlow}> {m.namespace} </ModelNode> ); }); } render() { const { coordinates } = this.props; if (!coordinates) return null; const ModelLabel = this.drawLabel(); return ( <div> <ModelLabel>MODELS</ModelLabel> { this.drawModelList() } </div> ); } } ModelGroup.propTypes = { coordinates: PropTypes.object, models: PropTypes.array, }; export default connect(({ dataflow }) => ({ dataflow }))(ModelGroup);
问题是,在 ModelGroup 中通过 this.props.dispatch 触发 action 不成功;但是在 DataFlowPanel 中可以
哪个位置触发不成功?
在 Paper children 中的组件:ModelGroup
有两个组件:分别为 DataFlowPanel\ModelGroup,项目是一个 dva project
DataFlowPanel 与 ModelGroup 关系
DataFlowPaper 具体实现:
ModelGroup 实现:
问题是,在 ModelGroup 中通过 this.props.dispatch 触发 action 不成功;但是在 DataFlowPanel 中可以