We had an issue wherein people were attempting to use strings as booleans in JavaScript. E.G.:
return (
<a>
{thisIsAString && ...
</a>
)
The assumption being that thisIsAString
would always return a truthy/falsy value. However, when used in a JSX/TSX context, the string actually gets treated as a string, yielding "text must be in <Text/>" console errors and logic failures.
To solve this, these cases need to be handled with a double-bang (!!
).
return (
<a>
{!!thisIsAString && ...
</a>
)
To find all of these usages, I used this regex to search in WebStorm. I was then able to examine the usages and make changes as needed.