Skip to content

Commit c6c38ea

Browse files
author
Robert Mosolgo
committed
Merge pull request #318 from markbrown4/master
remove unmountComponents on window unload
2 parents c189f27 + 0af02f6 commit c6c38ea

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,9 @@ The __view helper__ puts a `div` on the page with the requested component class
129129
```
130130

131131
On page load, the __`react_ujs` driver__ will scan the page and mount components using `data-react-class`
132-
and `data-react-props`. Before page unload, it will unmount components (if you want to disable this behavior,
133-
remove `data-react-class` attribute in `componentDidMount`).
132+
and `data-react-props`.
134133

135-
`react_ujs` uses Turbolinks events if they're available, otherwise, it uses native events.
134+
If Turbolinks is present components are mounted on the `page:change` event, and unmounted on `page:before-unload`.
136135
__Turbolinks >= 2.4.0__ is recommended because it exposes better events.
137136

138137
The view helper's signature is:

lib/assets/javascripts/react_ujs.js.erb

-2
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,8 @@
8989
function handleNativeEvents() {
9090
if ($) {
9191
$(function() {window.ReactRailsUJS.mountComponents()});
92-
$(window).unload(function() {window.ReactRailsUJS.unmountComponents()});
9392
} else {
9493
document.addEventListener('DOMContentLoaded', function() {window.ReactRailsUJS.mountComponents()});
95-
window.addEventListener('unload', function() {window.ReactRailsUJS.unmountComponents()});
9694
}
9795
}
9896

0 commit comments

Comments
 (0)