我尝试通过在渲染方法中编写以下 react 代码来编写 typescript 代码以在子组件中传播组件属性:
<MyComponent {...this.props}> </MyComponent>
typescript 编译器似乎不接受这种语法。任何解决方法?
最佳答案
似乎解决方法是改用 React.CreateElement : https://facebook.github.io/react/docs/transferring-props.html 在等待 typescript 时考虑此语法
关于 typescript 中的reactjs组件 Prop 传播,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34313542/