I have a Reactjs render method and I am trying to set a variable through a function. It looks like this (you guessed it , does not work):
render() {
let myVariable=''
//this function changes/sets myVariable
this.changeMyVariable()
return (
<div>{myVariable}</div>
);
}
How can I set a variable that is used in my render through another function, something like the example above. I also tried to use a state variable but the changeMyVariable() function runs twice.