react-modalでUncaught TypeError: Cannot read property 'appendChild' of null
Documentには...
Githubの公式Documentにはデフォルトではdocument.bodyがしていされるとのこと
/*
By default the modal is anchored to document.body. All of the following overrides are available.
* element
Modal.setAppElement(appElement);
* query selector - uses the first element found if you pass in a class.
Modal.setAppElement('#your-app-element');
*/
ただ、やってみると空でダメだった。前に使った時は特に何もせずとも動いていたので原因がわからなかった。なんとなく、DOMとjsの読み込みのタイミングの差かなと思っていろいろ調べてみたが、DOMはきちんと読み込まれているのにModal
解決策
jsxでModalの記述を行う直前に手動でdocument.bodyをセットしてあげると動いた。
ドキュメントを読むのをサボっていたのでかなり時間を食った。。。
コードを読むより、ReadMeがあるなら先にそっちをちゃんと読みましょう。。。。
Modal.setAppElement(document.body)