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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion javascript/webpacker_react-npm-module/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

} else {
console.error(`webpacker-react: cant render a component that has not been registered: ${className}`)
}
Expand Down
3 changes: 1 addition & 2 deletions javascript/webpacker_react-npm-module/src/ujs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

this.handleEvent('turbolinks:before-render', onUnmount)
},

Expand Down