Compatibility with Turbo (next version of Turbolinks)
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, rails, react
Research direction
Start with react_ujs/src/events/turbo.js and compare its proposed event handling with the existing Turbolinks integration. Then inspect the detection script and application.js hotfix to identify the required compatibility changes. Done means Turbo load and before-render events are supported without the manual hotfix.
Written by the indexing model from the issue text.
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.
- Dominant language
- JavaScript
- Stars
- 6.8k
- Forks
- 739
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from reactjs/react-rails
-
Documentation
Difficulty 4/5 3-5 days Newbie friendliness 45/100
reactjs/react-rails#1380 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
reactjs/react-rails#1355 · 1 comment · 1 reaction ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
reactjs/react-rails#1351 · 4 comments · 10 reactions ·
-
discussion
Difficulty 4/5 3-5 days Newbie friendliness 35/100
reactjs/react-rails#1341 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
reactjs/react-rails#1338 · 3 comments ·
All issues in reactjs/react-rails
Similar issues
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
githubnext/gh-aw-cao#13143 ·
-
status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100