【发布时间】:2016-08-24 22:11:44
【问题描述】:
全部:
我对 React 很陌生,我想知道如何在不添加任何元素(仅用于处理一些数据)的情况下构建仅逻辑组件,例如:
class LogicCom extends Component {
constructor(props){super(props);this.props = props;}
render(){
return (
{this.props.children}
)
}
}
【问题讨论】:
-
请注意,
return ({this.props.children})是无效的 JavaScript。{this.props.children}不是有效的对象文字。也许你在考虑 JSX,例如<div>{....}</div>。在这里,{...}有不同的语义,但在你的代码中没有 JSX。
标签: reactjs