import MyComponent from './MyComponent'
const { component, setComponent } = useState();
setComponent(MyComponent) // < how to pass props here?
后来在做类似的事情
const Component = () => component;
<Component />
在这种情况下,我在这里没有多大意义,只是想说明我需要如何传递道具
也许这可以帮助:
import MyComponent from './MyComponent'
const [component, setComponent] = useState(null);
setComponent(<MyComponent prop1="property"/>)
只需将一个函数传递给 state,它就会返回组件。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句