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

does not support server side rendering #39

Closed
trshafer opened this issue Feb 10, 2016 · 6 comments
Closed

does not support server side rendering #39

trshafer opened this issue Feb 10, 2016 · 6 comments

Comments

@trshafer
Copy link

Hey @gilbarbara,

Thanks for this library. It works great, however it does not support server side rendering. It would be totally ok to only show the tooltips on the client. The issue is the library cannot be required on the server due to accessing the window object on require or import.

Thanks,
Thomas

@gilbarbara
Copy link
Owner

Hey,

Yeah, I never tried it on server-side rendering. But I'm not sure how to implement this library without using the DOM.

If you know how to fix it, let me know.

@trshafer
Copy link
Author

Thanks for the quick response. There isn't really a way to use the library without the dom for parts such as positioning and scrolling. The issue is really that requiring the library tries to access window. It would be great to just make sure that window is defined in the initial require. Then it's practically a no-op for server side which should mostly be fine. The library is really great and the demo looks fantastic.

@gilbarbara gilbarbara added the bug label Feb 10, 2016
@gilbarbara
Copy link
Owner

hey!
Sorry for the delay, it has been a crazy couple of months!
I've made some tests but some of the modules that I require still uses window..
You could wrap you render block inside a jsdom env so it can use a mocked window object.

jsdom.env({
  html: '<!doctype html><html><body></body></html>',
  done: function (err, window) {
    if (err) {
      throw new Error(err);
    }

    global.window = window;
    global.navigator = window.navigator;

    var App = require('./components/App');
    console.log(ReactDOM.renderToStaticMarkup(<App />));
  }
});

@SunyoungKim508
Copy link

@gilbarbara where should I put that code?

@gilbarbara
Copy link
Owner

@SunyoungKim508
There was an update (433ea70) to skip the window object if it's not available.

If you still need it you could require an external script with Mocha, with --require path/to/your/require.js to initialize the jsdom window before running your tests.

@josebalius
Copy link

@gilbarbara 9640e19 this release seems to break with window errors again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants