'React function with fetched data- show n/a if empty : show fetched data

Hi I'm trying to create a condition in reactJS that if fetched data is empty then it should show "n/a" otherwise show fetched data. How to do that ? I would appreciate any help. Thank you.

const x =(text)

const myFunction = () => {
(x === null)? "n/a" : x}

//fetched component with data//

  <FetchedComponent>
 {text}
 </FetchedComponent>


Solution 1:[1]

return ({text !== null && <p>
 {text}
 </p>}
{text === null && <h3>n/a</h3>)

We dont need function.Try like this.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1