React beginner here, learning by coding, i have a project of mine where i have a small problem (this code is somehow near to my real code, cant share real code),
my question how can i have my newSnapshot for under a second to be this:
let newSnapshot =api/cam/${site.identifier}/+${allCams[0].identifier}/snapshot;
then after it automatically change to this:
let newSnapshot =api/cam/${site.identifier}/+${cam.identifier}/snapshot;
English is not my mother langugage so could be mistakes, any question just ask me.
const [state, setState] = useState({
snapshotUrl: "",
});
const updatePreview = () => {
const allCams=[{identifier: '7-7-7'}]
const site={identifier: '1-1-1'}
const cam={identifier: '0-0-0'}
let newSnapshot =
`api/cam/${site.identifier}/` +
`${cam.identifier}/snapshot`;
setState({
...state,
snapshotUrl: newSnapshot,
});
}