diff --git a/docs/building-features/turbolinks.md b/docs/building-features/turbolinks.md index c7d950ddc1..6a3129b78c 100644 --- a/docs/building-features/turbolinks.md +++ b/docs/building-features/turbolinks.md @@ -128,12 +128,21 @@ This definitely can make an app perform better, even if the JavaScript and style 1. Include turbolinks via yarn as shown in the [react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial/blob/8a6c8aa2e3b7ae5b08b0a9744fb3a63a2fe0f002/client/webpack.client.base.config.js#L22) or include the gem "turbolinks". 1. Included the proper "track" tags when you include the javascript and stylesheet: +**For Turbolinks 5.x:** + ```erb <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => 'reload' %> <%= javascript_include_tag 'application', 'data-turbolinks-track' => 'reload' %> ``` -NOTE: for Turbolinks 2.x, use `'data-turbolinks-track' => true` +**For Turbolinks 2.x (Classic):** + +```erb + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> + <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> +``` + +**Note:** If you're using modern Turbo (recommended), use `'data-turbo-track' => 'reload'` instead of `'data-turbolinks-track'`. See the "Using Turbo" section at the top of this document. 1. Add turbolinks to your `application.js` file: ```javascript diff --git a/react_on_rails_pro/spec/dummy/app/views/layouts/application.html.erb b/react_on_rails_pro/spec/dummy/app/views/layouts/application.html.erb index 9b57229e7b..1a9adec4ef 100644 --- a/react_on_rails_pro/spec/dummy/app/views/layouts/application.html.erb +++ b/react_on_rails_pro/spec/dummy/app/views/layouts/application.html.erb @@ -22,11 +22,11 @@ <%= stylesheet_pack_tag('client-bundle', media: 'all', - 'data-turbolinks-track': true) %> + 'data-turbo-track': 'reload') %> <%# Used for testing purposes to simulate hydration failure %> <% unless params[:skip_js_packs] == 'true' %> - <%= javascript_pack_tag('client-bundle', 'data-turbolinks-track': true, defer: false) %> + <%= javascript_pack_tag('client-bundle', 'data-turbo-track': 'reload', defer: false) %> <% end %> <%= csrf_meta_tags %> diff --git a/spec/dummy/app/views/layouts/application.html.erb b/spec/dummy/app/views/layouts/application.html.erb index ca89d84d47..54071c346e 100644 --- a/spec/dummy/app/views/layouts/application.html.erb +++ b/spec/dummy/app/views/layouts/application.html.erb @@ -10,7 +10,7 @@ <%= yield :head %> - <%= javascript_pack_tag('client-bundle', 'data-turbolinks-track': true) %> + <%= javascript_pack_tag('client-bundle', 'data-turbo-track': 'reload', defer: true) %> <%= csrf_meta_tags %>