In my react app I have state:
const [functions, setfunctions] = useState([{}]);
A test for undefined:
if (typeof functions[functionCount].url !== "undefined") {
imgSrc = functions[functionCount].url;
} else {
imgSrc = "";
}
And a JSX element that displays the URL if there is one:
<img style={{ width: "100%" }} src={imgSrc}></img>
How am I still getting this error?
.urlthat's undefined. It's the part before that that's undefined (functions[functionCount])