Я пытался удалить элемент из DOM и пытался использовать unmountComponentAtNode
, потому что я все еще каким-то образом регистрировал события щелчка. Однако, когда я пытаюсь запустить
handleClickOutside= async () =>{
console.log('the click is outside');
this.myRef = null;
var element = await document.getElementsByClassName('RequestDropDown_container');
if (element.length == 0) {
return
}
element[0].parentNode.removeChild(element[0]);
unmountComponentAtNode(element[0]); //error is happening here
}
, я получаю следующую ошибку в консоли
main.js:36 Uncaught (in promise) Error: Minified React error #40; visit https://reactjs.org/docs/error-decoder.html?invariant=40 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
at t.unmountComponentAtNode (VM4083 main.js:36)
at ba.<anonymous> (VM4083 main.js:52)
at Generator.next (<anonymous>)
at n (VM4083 main.js:1)
at s (VM4083 main.js:1)
Есть ли что-то, что я должен сделать по-другому