-
Notifications
You must be signed in to change notification settings - Fork 759
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
(JQuery 3 is incompatible) Helper method react_component not working unless I manually mount component #742
Comments
I'm having the same issue - components don't mount until I manually run |
I'm having the same issue too. |
Same here. Why is this happening? Is there a quick fix? |
@swrobel How do you call
|
I think I fixed my issue.
instead of
|
I have been seeing the same behavior using
|
I'm also having the same behavior, using this same version
|
Is there any error in your javascript console? Are you using any of:
? |
I am using Jquery only and don't have any console errors |
In the the following code: i added to my layout file and my component worked well Was my lack of attention, but I think a mention in the installation guides about adding |
I'm having trouble with this as well. Putting a For now, I've defined a separate layout with the pack tag for the pages of my app that use a React component, but I would prefer to get the |
I have the same problem but the javascript_pack_tag fix doesn't work for me. I get this error |
@AshrafLobo , javascript_pack_tag is a helper function from the Webpacker gem https://github.com/rails/webpacker/blob/master/lib/webpacker/helper.rb#L27 you can just use the javascript tag But from my experience, yes we still need to react ujs mount components |
I've noticed this is a problem only when I have any version of jQuery required in my Edit: Looks like if I move the jQuery require below |
Placing <% = javascript_pack_tag 'application'%> at the end of the "body" block worked for me. |
Hi all, |
I dig through the code a little and found out react-ujs assigned the function handleMount with the jQuery ready event if query exist. But the ready event was not fired for some reason. So just like @Deekor did, move the require for jQuery below, then the ujs will not use the jQuery ready event, but use the DOMContentLoaded event. |
Hmm it's a tough one, if jQuery isn't firing it's ready event due to some other application bug then there's likely nothing we can do to detect it, and we don't want to intentionally use DOMContentLoaded if jQuery is present. Seems like this thread seems to be gathering diverse comments that have a variety of causes, some not loading JS in right place, or right order or missing pack tags, enough to be worthy of documenting. Will reopen if there is any good solution to this, otherwise will likely add a mention to any future troubleshoot section. |
Ran into this as well and it was due to jquery3 removing |
Thanks @duckworth ! The problem is likely to be with this: |
Hey, I had this issue and I can confirm removing JQUERY fixed the problem. For reference I was using JQUERY version 3.2.1 via a script in application.html.erb
Using this version of JQUERY causes my react render methods to fail. For anyone looking for a solution, you can use version 2.2.4 instead
|
Help us help you! Please choose one:
react-rails
, so I've included the stack trace and the exact steps which make it crash.react-rails
with another library, but I'm having trouble. I've described my JavaScript management setup (eg, Sprockets, Webpack...), how I'm trying to use this other library, and why it's not working.Hi guys,
Great gem! I am facing an issue in which my <%= react_component %> helper is not displaying right away. If you notice in the screenshot "before.png", The inspector definitely shows this helper getting translated into the
data-react-class
html object. However, there is no HTML being rendered inside of it. THEN, I manually runReactRailsUJS.mountComponents()
after the page loads and as you can see in "after.png", it loads everything successfully!I've followed the instructions in the README as well as other tutorials, yet the helper is not working automatically. Please let me know if I can provide any additional information to debug this. Thank you!
Kristoph
before:
after:
The text was updated successfully, but these errors were encountered: