Uncaught Error: Unable to find element with ID with server side rendering
See original GitHub issueEverything works fine, except when doing initial page load via server side rendering. The error only occurs if I place anything inside the <Map></Map>
.
If I use client side rendering, everything works as expected.
My situation is something similar to:
let ReactMapboxGl
let Map
let ZoomControl
if (window) {
ReactMapboxGl = require('react-mapbox-gl')
ZoomControl = ReactMapboxGl.ZoomControl
Map = ReactMapboxGl.Map({
accessToken: '...',
scrollZoom: false,
})
}
...
render() {
return Map &&
<Map style="...">
<ZoomControl />
</Map>
}
The reason of the error is explained here https://github.com/facebook/react/issues/7093 . But I’m guessing there needs to be a solution for react-mapbox-gl to work with server side rendering. Any help is greatly appreciated!
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Receiving "Uncaught Error: Unable to find element with ID 15 ...
I've identified the element with this ID as being a imported from react-router-dom. I did find GitHub issues describing similar errors (one and ......
Read more >Using Cypress - Cypress Documentation
How do I get the native DOM reference of an element found using Cypress? ... from failing my test when my application throws...
Read more >NG8001: Unknown HTML element or component - Angular
Use the element name in the error to find the file(s) where the element is being used. Check that the name and selector...
Read more >Tag: Server-side Rendering - somewhat abstract
If all goes well and I remember what my fix was going to be, we will have a successfully server-side rendered application that...
Read more >Client Side Development with Spring Boot Applications
It is very easy to use and well suited to server-side rendering because it ... To get started with Spring Boot and client-side...
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
Which version of React is installed? The error is supposed to go away in React 16 ( https://github.com/facebook/react/issues/7093#issuecomment-333512582 ).
Thanks for the componentDidMount tip. I’ve previously rendered using a CLIENT global variable I set during file compilation, server or client bundle. I still don’t fully understand why the check after componentDidMount works instead of checking only if it’s client before it mounts. Maybe React allows dom updates after component did mount, but not before as it already has the server’s dom with react ids. Anyways, Thanks a lot!