module.exports = {
  // Turbolinks 5+ got rid of named events (?!)
  setup: function(ujs) {
  	ujs.handleEvent('turbolinks:load', ujs.handleMount);
    ujs.handleEvent('turbolinks:before-render', ujs.handleMount);
  },

  teardown: function(ujs) {
  	ujs.removeEvent('turbolinks:load', ujs.handleMount);
    ujs.removeEvent('turbolinks:before-render', ujs.handleMount);
  },
}

module.exports = {
  // Turbolinks 5+ got rid of named events (?!)
  setup: function(ujs) {
  	ujs.handleEvent('turbolinks:load', ujs.handleMount);
    ujs.handleEvent('turbolinks:before-render', ujs.handleUnmount);
  },

  teardown: function(ujs) {
  	ujs.removeEvent('turbolinks:load', ujs.handleMount);
    ujs.removeEvent('turbolinks:before-render', ujs.handleUnmount);
  },
}

Call handleUnmount before rendering a new page (#1020)