-
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
ReactRailsUJS: how to stop listening for events? #805
Comments
Good questions. If you're using something like webpacks then you could look into only loading those functions from react_ujs and calling them at will. |
Yeah, I also recommend taking a look at the implementation in this gem, then writing your own that works for you :) It sounds like you have pretty neat custom setup, so it might not be supported by react-rails out-of-the-box! |
@BookOfGreg, @rmosolgo thanks for quick response! Yes, I can import these methods from |
hey, everyone! If someone looking for solution, it's pretty easy ReactRailsUJS.removeEvent('turbolinks:render', ReactRailsUJS.handleMount);
ReactRailsUJS.removeEvent('DOMContentLoaded', ReactRailsUJS.handleMount);
$(window).on('load', function() {
ReactRailsUJS.handleMount();
ReactRailsUJS.detectEvents();
}) |
Thanks @anaumov ! |
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.Hello there!
Thank you for the awesome gem! I want to implement 'lazy' loading for my react components and render them after
window.onload
event fired. But ReactRailsUJS start watching for turbolinks events and render components during loading page (onturbolinks:load
). The page starts waiting and fireswindow.onload
event only after all react components rendered.How I can stop listening for events when ReactRailsUJS loaded? (I want to
mountComponents
manually on first load anddetectEvents
afterwords).Let me know if something is unclear in my description :)
The text was updated successfully, but these errors were encountered: