cjmling / findings

Notes on stuff i finds worth keeping for quick reference later on.
2 stars 0 forks source link

React conditional props #305

Open cjmling opened 2 years ago

cjmling commented 2 years ago

If we have component like this

<Text>
  label='outline'
  helperText='chandu'
  error=true
</Text>

And only want to set helperText and error only when error variable is true, then we can use spread operator

<Text>
  label='outline'
  { ...(error && {error:true, helperText:'chandu }
</Text>

More info. https://youtu.be/m-2_gb_3L7Q?t=8245

SEO react conditional props