Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable server side rendering for a given route #252

Open
baptwaels opened this issue Oct 21, 2016 · 1 comment
Open

Disable server side rendering for a given route #252

baptwaels opened this issue Oct 21, 2016 · 1 comment
Labels
V2.9.0 Express & server updates
Milestone

Comments

@baptwaels
Copy link

baptwaels commented Oct 21, 2016

Hi,

I try to set up a new react-leaflet component. When I try to access my route, I get an error :

ReferenceError: window is not defined
at Object. (.../leaflet/dist/leaflet-src.js:13043:3)

This error is totally fine because Leaflet needs access to the DOM to render properly.

Leaflet makes direct calls to the DOM when it is loaded, therefore this library is not compatible with server-side rendering. (here)

Is it possible to disable server side rendering for a given route ? What are the best practice to do so ?

Thank you :)

EDIT: I check before using my component if I'm on the browser or not. It works but I guess It's not a really nice way to do this... Any clues ?

if(process.title === 'browser'){
  //render my component
}else {
  return null
}
@luntegg
Copy link

luntegg commented Apr 25, 2017

I have same problem too with components react-sound and react-ionicons.

@mannyhenri mannyhenri added the V2.9.0 Express & server updates label Jun 2, 2018
@mannyhenri mannyhenri added this to the 2.9.0 milestone Jun 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V2.9.0 Express & server updates
Projects
None yet
Development

No branches or pull requests

3 participants