Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,9 @@ The __view helper__ puts a `div` on the page with the requested component class
```

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

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

The view helper's signature is:
Expand Down
2 changes: 0 additions & 2 deletions lib/assets/javascripts/react_ujs.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,8 @@
function handleNativeEvents() {
if ($) {
$(function() {window.ReactRailsUJS.mountComponents()});
$(window).unload(function() {window.ReactRailsUJS.unmountComponents()});
} else {
document.addEventListener('DOMContentLoaded', function() {window.ReactRailsUJS.mountComponents()});
window.addEventListener('unload', function() {window.ReactRailsUJS.unmountComponents()});
}
}

Expand Down