[英]Must use destructuring props assignment issue
I was making an app in react-native and when I try to put on text one of the values of props, I get an error message like this: Must use destructuring props assignment
我在 react-native 中制作了一个应用程序,当我尝试将道具值之一放在文本上时,我收到如下错误消息:
Must use destructuring props assignment
The code is this:代码是这样的:
<Text style={styles.SubTextButton}>
{props.date1} - {props.date2}
</Text>
and the props look like this:道具看起来像这样:
(props: {
text: string
date1: string
date2: string
})
The thing is, this actually don't ruin my app and all work well.问题是,这实际上不会破坏我的应用程序并且一切正常。 But I would like to know if it is maybe a question of format in the writing of the code or even an error of the ESlinter.
但是我想知道这是否可能是代码编写中的格式问题,甚至是ESlinter的错误。
You get this warning because in your Eslint set the rule: "react/destructuring-assignment": [<enabled>, 'always']
您收到此警告是因为在您的 Eslint 中设置了规则:
"react/destructuring-assignment": [<enabled>, 'always']
Eslint wants you write in this way with using destructuring assignment: Eslint 希望您使用解构赋值以这种方式编写:
const MyComponent = ({ date1, date2 }) => {
return (
<Text>
{date1} - {date2}
</Text>
)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.