ReactRailsUJS: how to stop listening for events?
See original GitHub issueHelp us help you! Please choose one:
- My app crashes with
react-rails
, so I’ve included the stack trace and the exact steps which make it crash. - My app doesn’t crash, but I’m getting unexpected behavior. So, I’ve described the unexpected behavior and suggested a new behavior.
- I’m trying to use
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. - I have another issue to discuss.
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 (on turbolinks:load
). The page starts waiting and fires window.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 and detectEvents
afterwords).
Let me know if something is unclear in my description 😃
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to: Stop listening to events - reactjs/react-rails GitHub Wiki
Based on discussion here: #805. If you want to stop listening to a specified event, it's possible to name the events to stop...
Read more >Stop event listening after route change - Stack Overflow
The solution I found consists in removing the event listener before unmounting the component. However, to do that I need to keep a...
Read more >Project: react-rails - The Ruby Toolbox
listen. ~> 3.0.0 ... Prevent installing default javascript dependencies by using ... Remove previous event handlers and add new ones: ReactRailsUJS.
Read more >How to (really) remove eventListeners in React
Sometimes you need to track user interaction like e.g. scrolling or events like the change of the win... Tagged with javascript, react, ...
Read more >Redux and React :: Full-stack web development "Hello World ...
... this allows Redux to do interesting things like keep an accurate ... to send event actions into a set of reducers that...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
hey, everyone! If someone looking for solution, it’s pretty easy
ReactRailsUJS
has methodremoveEvent
. You can stop listening for any event you like. For example render components on window load instead ofturbolinks:render
Thanks @anaumov ! I’ve added an entry to the Wiki with your example: https://github.com/reactjs/react-rails/wiki/How-to:-Stop-listening-to-events