-
Notifications
You must be signed in to change notification settings - Fork 751
Description
Issue
The next version of Turbolinks, now called Turbo (available for Rails via turbo-rails), is in beta and react-rails should be updated to be compatible. The new interface is similar to the old one, the events are just called differently.
The relevant events are now called turbo:load and turbo:before-render instead of turbolinks:load and turbolinks:before-render. A new event script along the following lines should do the trick:
// in react_ujs/src/events/turbo.js
module.exports = {
setup: function(ujs) {
ujs.handleEvent('turbo:load', ujs.handleMount);
ujs.handleEvent('turbo:before-render', ujs.handleUnmount);
},
teardown: function(ujs) {
ujs.removeEvent('turbo:load', ujs.handleMount);
ujs.removeEvent('turbo:before-render', ujs.handleUnmount);
},
}Along with this some changes to the detection script will be required, but I'm not familiar enough to be able to tell exactly what needs to be added.
Hotfix
I have solved this issue in my app by adding the following two lines to the application.js script:
// earlier: var ujs = require("react_ujs");
ujs.handleEvent('turbo:load', ujs.handleMount);
ujs.handleEvent('turbo:before-render', ujs.handleUnmount);For anyone already using Turbo and looking to also use react-rails, the above is a hotfix until it's implemented in the package.
Thanks to the contributors for taking a look at this.