Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper caching and mounting with Turbolinks 5 #28

Closed
wants to merge 1 commit into from
Closed

Proper caching and mounting with Turbolinks 5 #28

wants to merge 1 commit into from

Conversation

phil-monroe
Copy link

Fixes #27

Changes:

Follow the pattern of react-rails and always mount components on turbolinks:load whether initial HTML exists or not.

Please ensure that:

  • Changelog is updated if not a minor patch
  • Ruby linting is ok: rubocop is all green
  • Javascript linting is ok: cd javascript/webpacker_react-npm-module/ && yarn lint is all green
  • Tests are all green

@phil-monroe
Copy link
Author

I'm not really sure why the specs are failing... It seems webpack is compiling just fine so I'm not sure why webpacker is having issues finding the manifest.json.

@phil-monroe
Copy link
Author

By forcing webpacker to previous commit SHAs I can see that webpacker#a858f8e causes things to break

@@ -40,8 +40,7 @@ const ujs = {
},

turbolinks5(onMount, onUnmount) {
this.handleEvent('turbolinks:load', onMount, { once: true })
this.handleEvent('turbolinks:render', onMount)
this.handleEvent('turbolinks:load', onMount)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, before making a change read through this

This approach is just wrong if you use turbolinks caching feature

@@ -69,7 +69,7 @@ const WebpackerReact = {
const component = registeredComponents[className]

if (component) {
if (node.innerHTML.length === 0) this.render(node, component)
this.render(node, component)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is legit, IMHO

@ghost ghost closed this by deleting the head repository Oct 29, 2022
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Components don't re-mount after Turbolinks navigation
2 participants