目前我有一个类组件,其中包含在我的 JSX 中充当组件的函数。
例子:
class MyComponent extends React.Component {
MySubComponent = (props) => {
if (props.display) {
return <p>This text is displayed</p>
}
}
render() {
return (
<this.MySubComponent display={true} />
)
}
}
以这种方式调用组件有什么影响吗?还有这个术语吗?