I have a variable that I'm creating in componentDidMount()
and I'd like it to be available in componentDidUpdate()
. Any thoughts? Code looks like this:
class Example extends Component {
componentDidMount() {
const myVariable = 'this thing';
}
componentDidUpdate() {
// I'd like my variable to be accessible here
console.log(myVariable);
}
render() {...}
}