英文:
JSX expressions may not use the comma operator. Did you mean to write an array?
问题
I'm getting this error
JSX expressions may not use the comma operator. Did you mean to write an array?
on the following code snippets where I'm getting this error
<Text style={[theme.interRegular14], { fontWeight: 'bold' }}>No products bookmarked
I'm new to this codebase but found this error, but it didn't work.
Thanks
英文:
I'm getting this error
> JSX expressions may not use the comma operator. Did you mean to write an array?
on following code snippets where am getting this error
<Text style={[theme.interRegular14], { fontWeight: 'bold' }}>No products bookmarked</Text>
I'm new to this codebase but found this error but it didn't work.
Thanks
答案1
得分: 0
不要使用 ***`,`***。相反,你可以尝试这样做:
```js
<Text style={{fontWeight: 'bold',...theme.interRegular14 }}>未收藏任何产品</Text>
解释:
假设你有一个对象:
const theme = {
interRegular14: {
key1: "value1",
key2: "value1"
}
}
当你使用 theme.interRegular14
时,你会得到以下数据:
{
key1: "value1",
key2: "value1"
}
现在你可以使用这种方法将这个对象与新的键和值合并。
const newOBJ = {fontWeight: 'bold',...theme.interRegular14 }
现在这将返回最终的对象:
{
fontWeight: 'bold',
key1: "value1",
key2: "value1"
}
英文:
Don't use ,
. Instead, you can try this:
<Text style={{fontWeight: 'bold',...theme.interRegular14 }}>No products bookmarked</Text>
Explanation:
Let's say you have an object:
const theme = {
interRegular14: {
key1: "value1",
key2: "value1"
}
}
And when you use theme.interRegular14
. You get this following data:
{
key1: "value1",
key2: "value1"
}
Now you can use this method to merge this object with new keys and values.
const newOBJ = {fontWeight: 'bold',...theme.interRegular14 }
Now this will return the final object as:
{
fontWeight: 'bold',
key1: "value1",
key2: "value1"
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论