Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.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
Javascript 如何将React组件作为道具传递_Javascript_Reactjs_Semantic Ui_Semantic Ui React - Fatal编程技术网

Javascript 如何将React组件作为道具传递

Javascript 如何将React组件作为道具传递,javascript,reactjs,semantic-ui,semantic-ui-react,Javascript,Reactjs,Semantic Ui,Semantic Ui React,我正在使用react语义ui模态对象。 打开模态的对象是一个道具 <Modal trigger=<Button>Text</Button> otherProp=... > </Modal> 我想在另一个组件中嵌入模态: export default class Confirm extends Component { render() { return (

我正在使用react语义ui模态对象。 打开模态的对象是一个道具

 <Modal
       trigger=<Button>Text</Button>
       otherProp=...
   >
  </Modal>

我想在另一个组件中嵌入模态:

export default class Confirm extends Component {

    render() {
        return (
            <Modal
                trigger={this.props.trigger} /* here */
              >    
                <Modal.Content>
                    ...
                </Modal.Content>
                <Modal.Actions>
                    ...
                </Modal.Actions>
            </Modal>
        )
    }
}
导出默认类确认扩展组件{
render(){
返回(
...
...
)
}
}

如何将JSX代码(
Text
)作为道具传递,以作为模式道具呈现?

您可以轻松地执行以下操作

<Modal trigger={ <Button>Text</Button> }> 
   // content goes here 
</Modal>

谢谢我的问题是如何在模态标记定义中呈现
this.props.trigger
。我想以propHi@znat的身份通过
Text
,我已经回答了;),您可以像任何其他字符串属性或变量一样,在
模式中打印它
{this.props.trigger}
在你的
渲染
方法中,我认为有一个误解:我需要这样的东西://内容放在这里,但这不起作用。这能回答你的问题吗?
render () {
    return (
        <div>
            // some code can go here
            { this.props.trigger }
        </div>
    );
}