Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I use this operator all the time in a similar but not quite the same way:

<input type=“text” defaultValue={user.email ?? “”}>

The user is an entity from the DB, where the email field is nullable, which makes perfect sense. The input component only accepts a string for the defaultValue prop. So you coalesce the possible null to a string.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: