I’m working on a project for displaying upcoming tech events. Inside the data object I get from the backend app there’s an object for the location of the event. Inside the location
object there’s a property named @type
which indicates whether the event is online or at a physical location. I need to check the value of this property to conditionally determine whether I need to render data from an address
object or the value of a url
property.
If I try accessing it like this
{location.@type === 'virtualLocation' && <p>Online</p>}
I get an error because the @
symbol is being regarded as a decorator. I I remove the @
symbol and just do location.type
I get an undefined
error. I tried doing
{location['@type'] === 'virtualLocation' && <p>Online</p>}
and while I didn’t get an error, nothing renders.
I don’t know what database is being used as I didn’t write the backend nor do I have any control over that side of the project to remove the @
symbol, how how do I go about checking the value of this @type
property?