Answers for "conditional props react"

4

conditional jsx property

render() {
  return (
    <a className="navbar-brand" {... url ? {href: url} : {}}>Logo</a>
  )
}
Posted by: Guest on February-28-2020
1

conditional props react

// single prop
propName={ condition ? something : somethingElse }
propName={ condition && something }
// multiple props
{ ...( condition ? { ...setOfProps } : { ...setOfOtherProps })}
{ ...( condition && { ...setOfProps })}
Posted by: Guest on January-21-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language