Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将react渲染与AngularJs和ngReact一起使用_Angularjs_Reactjs_Ngreact - Fatal编程技术网

如何将react渲染与AngularJs和ngReact一起使用

如何将react渲染与AngularJs和ngReact一起使用,angularjs,reactjs,ngreact,Angularjs,Reactjs,Ngreact,我正在尝试使用angularJs应用程序中的库 在下面的代码中,我在库中创建了一个类,该类使用webpack作为single bundle.js绑定 window.HelloStormReact = React.createClass({ render: function() { var Engine = require("../src/Engine")(); var model = {links:[],nodes: []}; function generateSet(model,of

我正在尝试使用angularJs应用程序中的库

在下面的代码中,我在库中创建了一个类,该类使用webpack作为single bundle.js绑定

window.HelloStormReact =  React.createClass({

render: function() {

var Engine = require("../src/Engine")();

var model = {links:[],nodes: []};

function generateSet(model,offsetX,offsetY){

                    var node1 = Engine.UID();
    var node2 = Engine.UID();
    var node3 = Engine.UID();
    var node4 = Engine.UID();
    var node5 = Engine.UID();


    model.links = model.links.concat([
        {
            id: Engine.UID(),
            source: node1,
            sourcePort: 'out',
            target: node2,
            targetPort: 'in',
        },
        {
            id: Engine.UID(),
            source: node1,
            sourcePort: 'out',
            target: node3,
            targetPort: 'in'
        },
        {
            id: Engine.UID(),
            source: node2,
            sourcePort: 'out',
            target: node4,
            targetPort: 'in'
        },
        {
            id: Engine.UID(),
            source: node4,
            sourcePort: 'out',
            target: node5,
            targetPort: 'in2'
        },
        {
            id: Engine.UID(),
            source: node2,
            sourcePort: 'out',
            target: node5,
            targetPort: 'in'
        }
    ]);

    model.nodes = model.nodes.concat([
    {
            id:node1,
            type: 'action',
            data: {
                name: "Create User",
                outVariables: ['out']
            },
            x:50 + offsetX,
            y:50 + offsetY
        },
        {
            id:node2,
            type: 'action',
            data: {
                name: "Add Card to User",
                inVariables: ['in','in 2'],
                outVariables: ['out']
            },
            x:250 +offsetX,
            y:50 + offsetY
        },
        {
            id:node3,
            type: 'action',
            data: {
                color: 'rgb(0,192,255)',
                name: "Remove User",
                inVariables: ['in']
            },
            x:250 + offsetX,
            y:150 + offsetY
        },
        {
            id:node4,
            type: 'action',
            data: {
                color: 'rgb(0,192,255)',
                name: "Remove User",
                inVariables: ['in'],
                outVariables: ['out']
            },
            x:500 + offsetX,
            y:150 + offsetY
        },
        {
            id:node5,
            type: 'action',
            data: {
                color: 'rgb(192,255,0)',
                name: "Complex Action 2",
                inVariables: ['in','in2','in3']
            },
            x:800 + offsetX,
            y:100 + offsetY
        },
    ]);
                }

generateSet(model,0,0);

Engine.registerNodeFactory({
    type:'action',
    generateModel: function(model){
        return React.createElement(BasicNodeWidget,{
            removeAction: function(){
                Engine.removeNode(model);
            },
            color: model.data.color,
            node: model,
            name: model.data.name,
            inPorts: model.data.inVariables,
            outPorts: model.data.outVariables
        });
    }
});

Engine.loadModel(model);

return ReactDOM.render(React.createElement(Canvas,{engine: Engine}), document.getElementById("howdy"));;
}
});
在index.html中,我使用了在Storm react库模块中创建的类

 <div class="content">
   <react-component name="HelloStormReact" />
   <div class="storm-flow-canvas" id="howdy">
   </div>
</div>
请帮助我编写要返回的正确渲染对象。

由于HelloStormReact只是一个组件,在其渲染函数中,您不需要再次渲染它,只需在渲染函数中返回React.createElementCanvas,{engine:engine}

    Constructor.render(): A valid React element (or null) must be returned. 
   You may have returned undefined, an array or some other invalid object.