From 7ad5c1392004b9f326aadb13bf10746ba6495e1b Mon Sep 17 00:00:00 2001 From: Sergey Zyablitsky Date: Sat, 11 Feb 2017 16:49:26 +1000 Subject: [PATCH] Change Turbolinks unmount event from before-visit to before-render (#709) * change turbolinks unmount event from before-visit to before-render * Addresses #706 --- CHANGELOG.md | 2 ++ docs/additional-reading/turbolinks.md | 2 +- docs/api/javascript-api.md | 2 +- node_package/src/clientStartup.js | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f1824bbe..84bf1e729 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ Contributors: please follow the recommendations outlined at [keepachangelog.com] ## [Unreleased] *Please add entries here for your pull requests.* +### Fixed +- Fixed issue [#706](https://github.com/shakacode/react_on_rails/issues/706) with "flickering" components when they are unmounted too early [#709](https://github.com/shakacode/react_on_rails/pull/709) by [szyablitsky](https://github.com/szyablitsky) ## [6.5.0] - 2017-01-31 ### Added diff --git a/docs/additional-reading/turbolinks.md b/docs/additional-reading/turbolinks.md index 725ea7564..7b8adb0da 100644 --- a/docs/additional-reading/turbolinks.md +++ b/docs/additional-reading/turbolinks.md @@ -94,7 +94,7 @@ TURBO: reactOnRailsPageLoaded Turbolinks 5: ``` -TURBO: WITH TURBOLINKS 5: document turbolinks:before-cache and turbolinks:load handlers installed. (program) +TURBO: WITH TURBOLINKS 5: document turbolinks:before-render and turbolinks:load handlers installed. (program) TURBO: reactOnRailsPageLoaded ``` diff --git a/docs/api/javascript-api.md b/docs/api/javascript-api.md index 104f5f954..5a4a68201 100644 --- a/docs/api/javascript-api.md +++ b/docs/api/javascript-api.md @@ -6,7 +6,7 @@ The best source of docs is the main [ReactOnRails.js](../../node_package/src/Rea * Main entry point to using the react-on-rails npm package. This is how Rails will be able to * find you components for rendering. Components get called with props, or you may use a * "generator function" to return a React component or an object with the following shape: - * { renderedHtml, redirectLocation, error }. + * { renderedHtml, redirectLocation, error }. * @param components (key is component name, value is component) */ register(components) diff --git a/node_package/src/clientStartup.js b/node_package/src/clientStartup.js index 15d01d0e4..f3eb4848e 100644 --- a/node_package/src/clientStartup.js +++ b/node_package/src/clientStartup.js @@ -183,8 +183,8 @@ export function clientStartup(context) { if (turbolinksVersion5()) { debugTurbolinks( 'USING TURBOLINKS 5: document added event listeners ' + - ' turbolinks:before-visit and turbolinks:load.'); - document.addEventListener('turbolinks:before-visit', reactOnRailsPageUnloaded); + 'turbolinks:before-render and turbolinks:load.'); + document.addEventListener('turbolinks:before-render', reactOnRailsPageUnloaded); document.addEventListener('turbolinks:load', reactOnRailsPageLoaded); } else { debugTurbolinks(