I have a custom hook that fetches data and then I want to display that data.
But it isn't available at render so I've been doing this
<li>{data && data.name}</li>
Is there a better way?
I have a custom hook that fetches data and then I want to display that data.
But it isn't available at render so I've been doing this
<li>{data && data.name}</li>
Is there a better way?
I would do something like this
{data.name &&
<li>{data.name}</li>
}
This way the tag is only rendered if the exact value exists otherwise no element will be rendered.