Next.js Discord

Discord Forum

how to shorten this

Unanswered
American Chinchilla posted this in #help-forum
Open in Discord
American ChinchillaOP
i have this case
<PeopleIcon fill={clients > 0 ? "#003366" : undefined} />


i tried
<PeopleIcon fill={clients > 0 && "#003366"} />
but it says

Type 'false | "#003366"' is not assignable to type 'string | undefined'.
  Type 'boolean' is not assignable to type 'string'.

3 Replies

Netherland Dwarf
Hmm why do you want to shorten it- i think this is as close as you can shorten
Shorten code isnt always the best.
Its always better to have readable code over fancy short code