storybook: Uncaught Error: Target container is not a DOM element.
I am getting this error since upgrading from 3.2.18 to 3.3.3:
Uncaught Error: Target container is not a DOM element.
at invariant (invariant.js:42)
at renderSubtreeIntoContainer (react-dom.development.js:15180)
at Object.render (react-dom.development.js:15290)
at exports.default (routes.js:39)
at App.init (app.js:119)
at exports.default (index.js:41)
at Object.<anonymous> (index.js:16)
at __webpack_require__ (bootstrap 77c5cb83d0653d7a60e4:678)
at fn (bootstrap 77c5cb83d0653d7a60e4:88)
at Object.defineProperty.value (fuse.js:996)
And the page is just showing the following text:
/static/media/index.html.3cbc7277.ejs
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 31 (15 by maintainers)
Commits related to this issue
- Storybook upgrade broke with our config As part of an unintentional bump of the storybook version in e8f9c1dfc6c143c834d11bf68d8070cb3597b68e it would no longer run correctly. The issue was already ... — committed to ONSdigital/eq-author by tgandrews 6 years ago
- Storybook upgrade broke with our config As part of an unintentional bump of the storybook version in e8f9c1dfc6c143c834d11bf68d8070cb3597b68e it would no longer run correctly. The issue was already ... — committed to ONSdigital/eq-author by tgandrews 6 years ago
- Storybook upgrade broke with our config As part of an unintentional bump of the storybook version in e8f9c1dfc6c143c834d11bf68d8070cb3597b68e it would no longer run correctly. The issue was already ... — committed to ONSdigital/eq-author by tgandrews 6 years ago
If there is someone who hasn’t fix the problem jet, check the order of your tag elements in html. For example I wrote ( accidentally )
But the script tag should be below the DOM element. I’ve lost 2h on this 😕 Cheers!
You don’t have to remove the file loader, just exclude
*.ejs:Thank you, I have found the solution to the problem thanks to your reproduction repo ❤️
Here’s the required change: https://github.com/aaronfullerton/storybook-issue-2615/pull/1
@ndelangen sure, You can try this: https://github.com/aaronfullerton/storybook-issue-2615
I pulled this from our existing codebase and attempted to remove as much noise as possible. My apologies if there’s still a bit of unnecessary code in there.
It looks like an error indicating the “root” dom element for targeting/mounting from js was not found.
Check in your html file if the id attribute has the same name as ReactDOM.render(<App />, document.getElementById(‘index’));
What if my webpack config doesn’t use file-loader and I’m seeing this?
Running:
Webpack config:
storybook .babelrc
Excellent, thank you. I can confirm this solves the problem. I’ll look into updating the docs to indicate this.
is this the same issue? i have the right lines of code but it doesnt resolve, is it a webpack error?
I am having this exact same problem apparently because I am changing the id of
roottoapp-root. I am doing this because I would like the dom in my storybook to look just like the dom of my application. This also makes it easier to test modals and so on. Currently I am doing this via a global decorator that basically does this:Is there any better way of doing this?