I'm trying to use a ternary operator inside an image tag to toggle between two sets of gifs. It isn't working. Is my syntax messed up, or can I just not do this? Any suggestions? (code below)
import React, { useState } from 'react'
const Artist = ({currentArtist}) => {
const ghostify = () => {
if(isGhost) {
setIsGhost(!isGhost)
}
}
//state
const [isGhost, setIsGhost] = useState(false)
return (
<div className="artist">
<img src={isGhost ? currentArtist.vid : currentArtist.ghostVid} alt=
{currentArtist.name} />
<h2>{currentArtist.name}</h2>
<h3>{currentArtist.title}</h3>
<button onClick={ghostify()}>Ghostify</button>
</div>
)
}
export default Artist