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

script async=true prevents react_ujs from working when prerendering #218

Closed
blainekasten opened this issue Mar 20, 2015 · 5 comments
Closed

Comments

@blainekasten
Copy link

as title states. If I make my javascript_include_tag 'application', async: true then the server side rendered items are never reconciled.

@rmosolgo
Copy link
Member

Hum, I wonder if it just misses the document.DOMContentLoaded event?

https://github.com/reactjs/react-rails/blob/master/lib/assets/javascripts/react_ujs.js.erb#L89

@SqueezedLight
Copy link

Hi, seems i can not get things working with javascript_include_tag 'application', async: true

Any ideas how to fix that?

Thanks!

@rmosolgo
Copy link
Member

rmosolgo commented Sep 5, 2015

I suspect it's the same issue as described here:

http://stackoverflow.com/questions/9237044/async-loaded-scripts-with-domcontentloaded-or-load-event-handlers-not-being-call

Because the react-rails UJS mounts components on DOMContentLoaded: https://github.com/reactjs/react-rails/blob/master/lib/assets/javascripts/react_ujs.js.erb#L90-L94

You could mount components manually at the end of your script with

ReactRailsUJS.mountComponents()

@SqueezedLight
Copy link

Ok ,thanks for your help. That solved the problem.

@rmosolgo rmosolgo closed this as completed Sep 5, 2015
@rmosolgo
Copy link
Member

rmosolgo commented Sep 5, 2015

🎉

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

3 participants