componentDidMount() {
if (process.env.NODE_ENV !== 'production') {
if (!is.domElement(this.beacon)) {
console.warn('beacon is not a valid DOM element'); //eslint-disable-line no-console
}
}
if (is.domElement(this.beacon)) {
setTimeout(() => {
this.beacon.focus();
}, 0);
}
}
Looks like in this case, the callback in setTimeout is executed after the component is unmounted and link to the beacon is lost. Is there any particular reason why there is if condition outside of setTimeout?
I tried this:
setTimeout(() => {
if (is.domElement(this.beacon)) {
this.beacon.focus();
}
}, 0);
It seems to be working. I checked it with our project and with the react-joy-demo project, there are no behaviour changes.
Is it ok if I create PR with those changes?
🐛 Bug Report
Error in console
To Reproduce
Steps to reproduce the behaviour:
Expected behaviour
No error
In react-joyride/src/components/Beacon.js:63
Looks like in this case, the callback in setTimeout is executed after the component is unmounted and link to the beacon is lost. Is there any particular reason why there is if condition outside of setTimeout? I tried this:
It seems to be working. I checked it with our project and with the react-joy-demo project, there are no behaviour changes. Is it ok if I create PR with those changes?