我看到了一些像这样的示例代码:
import React from 'react'
import MyComp from 'my-comp'
const MySubComp = MyComp.MySubComp
class Page extends React.Component {
render() {
return (
<MyComp>
<MySubComp/>
</MyComp>
)
}
}
如何实现语法MyComp.MySubComp
?
是否有术语?
答案 0 :(得分:11)
在您的示例中,MySubComp
是MyComp
的静态类成员,您可以轻松地实现它:
export default class MyComp extends Component {
// ...
}
MyComp.MySubComp = class MySubComp extends Component {
// ...
}