ssorallen / turbo-react

A JavaScript library that transitions between static HTML pages on navigation; no app server required.
https://turbo-react.herokuapp.com/
Apache License 2.0
273 stars 16 forks source link

global is not defined error #30

Closed dm123455 closed 7 years ago

dm123455 commented 8 years ago

I am trying to use turbolinks in our rails application. The gems that I was initially using are jquery-turbolinks and turbolinks. But my react component does not show up after adding them into my application. So I went ahead and added turbo_react-rails into my app(in addition to jquery-turbolinks and turbolinks), but it throws 'global is not defined error'. What am I doing wrong?

mjcloutier commented 8 years ago

getting the same global is undefined.

var originalReplaceChild =
  global.document.documentElement.replaceChild.bind(
    global.document.documentElement);
mjcloutier commented 8 years ago

Looks like getting this as well: Uncaught TypeError: HTMLtoJSX is not a constructor

var converter = new HTMLtoJSX({createClass: false});

Is there an extra dependency required to run this in a rails app?

dLobatog commented 7 years ago

I'm getting the same when evaluating if (global.Turbolinks === undefined) {, - global itself isn't defined.

dLobatog commented 7 years ago

I see the latest release uses if (window.Turbolinks === undefined) {, which is indeed defined on my setup too. @ssorallen can we expect a new release?

ssorallen commented 7 years ago

I just released the 'turbo_react-rails' gem with the version of the 'turbo-react' that fixes the global error. v0.9.0 should fix the issue you're seeing. Try upgrading your gems, and let me know if you see other problems.