undefinedfix
Sign in

How to call function 2 inside render () {return (function 2)} outside react?

mrswats edited in Fri, 25 Nov 2022

Objective: by triggering ondragstart ={ this.onDragStart }If you do not use ondragstart in the < tree > tag, you can call function 2 directly. Of course, < tree > tag is provided by ant design

If yes, how to operate? There is a detailed explanation at the bottom

classFlowItemPanelextendsReact.Component {
    onDragStart = info => {  // 我是函数1
    }

    render(){   
        return( 
      <ItemPanel>      //GG-Editor拖动结构 
            <Item>       //<Item>底部有展示
            function2()            // 我是函数2
            </Item>
          </ItemPanel>
          
          <Tree                //树菜单
          draggable
          defaultExpandAll="true"
          onDragStart = {this.onDragStart}// 调用函数1
          >
           <TreeNode title="数据主题" key="0-0">
          </Tree>
    

        )
    }

}
exportdefaultFlowItemPanel;

=====================================Or GG editor drag problem. The original left graphics into a tree menu

1. Changed to text, change < item > to double label, and add text inside. 2. Put the antd tree type draggable menu, which displays normally and can be dragged. But the canvas on the right side can't be recognized. Because a specific structure is needed, set the tree type menu and call the method when dragging (ondragstart = 0{ this.onDragStart }), Return returns a structure required by GG editor, that is, < itempanel > < item > < / item > < itempanel >. However, the returned function is outside of render {return()} and cannot be returned to return(). So I want to call a function inside return() again

< item > structure:

<Item
          type="node"
          size="72*72"
          shape="flow-circle"
          model={{
            color: "#FA8C16",
            label: "车辆信息表",
            id: '111111'
          }}
        >
        <span style={{"user-select" : "none"}}>666数据表文件</span>
</Item>
0 Replies