#How can we make a div content optional?

1 messages · Page 1 of 1 (latest)

dusky bramble
#

Hi,
how can we make a div optional if we are not passing any content in that particular component and it is taking up the unwanted space in the UI?

Heading Component

#

Using in this way to render the title

brisk otter
#

Could do something like...
{title && <h1>{title}</h1>}

dusky bramble
#

and what if we need to add some more p tags ?
from where it is getting the data

brisk otter
#

Not sure I understand exactly, but you can wrap a check around multiple elements.

dusky bramble
#

I tried with image in this way but the image is not showing up

Is this right ?

brisk otter
#

I don't believe the parenthesis around the image tag should be there.

dusky bramble
#

image is also optional sometimes it shows blank space

brisk otter
#

What does {image} return?

dusky bramble
#

string

#

image path

brisk otter
#

So in the 2nd screenshot, does image, alt and classes return data if you write them out separately?

dusky bramble
#

that all are optional i can add the data