Skip to content

Commit 70add3f

Browse files
authored
Merge pull request #868 from BookOfGreg/fix-848
Fix double mount in Turbolinks #848
2 parents f17376f + 8070621 commit 70add3f

File tree

6 files changed

+8
-23
lines changed

6 files changed

+8
-23
lines changed

lib/assets/javascripts/react_ujs.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,14 +422,12 @@ module.exports = {
422422
module.exports = {
423423
// Turbolinks 5+ got rid of named events (?!)
424424
setup: function(ujs) {
425-
ujs.handleEvent('DOMContentLoaded', ujs.handleMount)
426-
ujs.handleEvent('turbolinks:render', ujs.handleMount)
425+
ujs.handleEvent('turbolinks:load', ujs.handleMount)
427426
ujs.handleEvent('turbolinks:before-render', ujs.handleUnmount)
428427
},
429428

430429
teardown: function(ujs) {
431-
ujs.removeEvent('DOMContentLoaded', ujs.handleMount)
432-
ujs.removeEvent('turbolinks:render', ujs.handleMount)
430+
ujs.removeEvent('turbolinks:load', ujs.handleMount)
433431
ujs.removeEvent('turbolinks:before-render', ujs.handleUnmount)
434432
},
435433
}

lib/react/rails/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ module React
22
module Rails
33
# If you change this, make sure to update VERSIONS.md
44
# and republish the UJS by updating package.json and `bundle exec rake ujs:publish`
5-
VERSION = '2.4.3'
5+
VERSION = '2.4.4.pre'
66
end
77
end

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react_ujs",
3-
"version": "2.4.3",
3+
"version": "2.4.4-PRE",
44
"description": "Rails UJS for the react-rails gem",
55
"main": "react_ujs/index.js",
66
"files": [
@@ -12,8 +12,5 @@
1212
},
1313
"devDependencies": {
1414
"webpack": "^2.3.3"
15-
},
16-
"dependencies": {
17-
"react_ujs": "^2.4.3"
1815
}
1916
}

react_ujs/dist/react_ujs.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,14 +422,12 @@ module.exports = {
422422
module.exports = {
423423
// Turbolinks 5+ got rid of named events (?!)
424424
setup: function(ujs) {
425-
ujs.handleEvent('DOMContentLoaded', ujs.handleMount)
426-
ujs.handleEvent('turbolinks:render', ujs.handleMount)
425+
ujs.handleEvent('turbolinks:load', ujs.handleMount)
427426
ujs.handleEvent('turbolinks:before-render', ujs.handleUnmount)
428427
},
429428

430429
teardown: function(ujs) {
431-
ujs.removeEvent('DOMContentLoaded', ujs.handleMount)
432-
ujs.removeEvent('turbolinks:render', ujs.handleMount)
430+
ujs.removeEvent('turbolinks:load', ujs.handleMount)
433431
ujs.removeEvent('turbolinks:before-render', ujs.handleUnmount)
434432
},
435433
}

react_ujs/src/events/turbolinks.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
module.exports = {
22
// Turbolinks 5+ got rid of named events (?!)
33
setup: function(ujs) {
4-
ujs.handleEvent('DOMContentLoaded', ujs.handleMount)
5-
ujs.handleEvent('turbolinks:render', ujs.handleMount)
4+
ujs.handleEvent('turbolinks:load', ujs.handleMount)
65
ujs.handleEvent('turbolinks:before-render', ujs.handleUnmount)
76
},
87

98
teardown: function(ujs) {
10-
ujs.removeEvent('DOMContentLoaded', ujs.handleMount)
11-
ujs.removeEvent('turbolinks:render', ujs.handleMount)
9+
ujs.removeEvent('turbolinks:load', ujs.handleMount)
1210
ujs.removeEvent('turbolinks:before-render', ujs.handleUnmount)
1311
},
1412
}

yarn.lock

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,12 +1314,6 @@ rc@^1.1.7:
13141314
minimist "^1.2.0"
13151315
strip-json-comments "~2.0.1"
13161316

1317-
react_ujs@^2.4.2, react_ujs@^2.4.3:
1318-
version "2.4.3"
1319-
resolved "https://registry.yarnpkg.com/react_ujs/-/react_ujs-2.4.3.tgz#f35b641f248a155ad3539468c5463734fce4fe4a"
1320-
dependencies:
1321-
react_ujs "^2.4.2"
1322-
13231317
read-pkg-up@^1.0.1:
13241318
version "1.0.1"
13251319
resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02"

0 commit comments

Comments
 (0)