react state to className code example
Example: use state in className
Standard fair:
const [toggleClass, setToggleClass] = useState(false)
return <div className={toggleClass ? 'some-class' : ''} />
Using template literals:
const [toggleClass, setToggleClass] = useState(false)
return <div className={`some-class ${toggleClass ? 'some-class' :''}`} />