'appendChild' of null in scrollbarSize.js:18
See original GitHub issueI get this error when I run your example code:
scrollbarSize.js:18 Uncaught TypeError: Cannot read property 'appendChild' of null
at exports.default (scrollbarSize.js:18)
at Object.<anonymous> (index.js:138)
at __webpack_require__ (bootstrap 1891148…:19)
at Object.<anonymous> (bundle.js:5069)
at Object.exports.__esModule (bundle.js:5561)
at __webpack_require__ (bootstrap 1891148…:19)
at Object.<anonymous> (index.js:3)
at __webpack_require__ (bootstrap 1891148…:19)
at Object.<anonymous> (entry.jsx:3)
at __webpack_require__ (bootstrap 1891148…:19)
Steps to reproduce:
npm install babel-core babel-loader babel-preset-es2015 babel-preset-react css-loader react react-addons-css-transition-group react-dom react-infinite-calendar style-loader webpack --save
- create
webpack.config.js
- create
index.html
with<div id='root'></div>
webpack
- copy paste example into
entry.jsx
- open
index.html
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Uncaught TypeError: Cannot read property 'appendChild' of null
The "Cannot read property 'appendChild' of null" error occurs for 2 reasons: Calling the appendChild() method on a DOM element that doesn't ...
Read more >TypeError: Cannot read property 'appendChild' of Null in JS
The "Cannot read property 'appendChild' of null" error occurs for 2 reasons: Calling the appendChild() method on a DOM element that doesn't exist,...
Read more >Incident Response - Hybrid Analysis
appendChild (scrollDiv);mfp.scrollbarSize = scrollDiv.offsetWidth - scrollDiv.clientWidth;document.body.removeChild(scrollDiv);}return mfp.scrollbarSize;}} ...
Read more >https://www.museomadignano.it/pages/build/IWT.min....
getComputedStyle(element, null);\n return property ? css[property] : css ... rect.top\n };\n\n // subtract scrollbar size from sizes\n var sizes = element.
Read more >TypeError: Cannot read property 'appendChild' of null bpm ...
I tried implementing bpmn in reactjs using this source https://github.com/bpmn-io/bpmn-js-properties-panel , so I've written a route for my ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@dben89x yes, @clauderic is correct that you can solve the problem by moving your
<%= javascript_include_tag 'application' %>
out of the<head>
and into the end of the<body>
, although I’m not clear on whyreact_on_rails
is not handling this sort of thing. You can see a similar discussion here on thereact-big-calendar
repo.This is the line that’s causing an error: https://github.com/react-bootstrap/dom-helpers/blob/master/src/util/scrollbarSize.js#L16
The only scenario where
document.body
would be undefined is if you’re trying to access it before it’s declared (i.e., if your script is in the<head>
of the page).Either place your script at the end of the
<body>
tag or defer the javascript from being initialized until the document is ready.