React Native:将内联样式属性传递给组件时出现错误“属性‘样式’在类型‘IntrinsicAttributes & ... 上不存在”

Ken*_*y83 5 typescript reactjs react-native

通过阅读其他问题/答案,我了解了这个问题的解决方案(只需添加style到我的组件的 props 对象),但我不明白为什么这是必要的。

不是style一个吗IntrinsicAttribute?!如果是这样,为什么有必要在我的组件的 props 对象中显式定义它,如下所示:

export const MyComponent = ({ ...other props, style }) => {
    // Component body redacted for brevity
};
Run Code Online (Sandbox Code Playgroud)