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
>Solution :
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"
}