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

Resolve double mounting error with Turbo(links) #1421

Closed
wants to merge 6 commits into from

Conversation

Judahmeek
Copy link
Contributor

@Judahmeek Judahmeek commented Jan 14, 2022

Fixes #1139


This change is Reviewable

@@ -61,7 +61,8 @@ The best source of docs is the main [ReactOnRails.js](https://github.com/shakaco
/**
* Set options for ReactOnRails, typically before you call ReactOnRails.register
* Available Options:
* `traceTurbolinks: true|false Gives you debugging messages on Turbolinks events
* `traceTurbolinks: true|false` Gives you debugging messages on Turbolinks events
* `turbo: true|false` enables Turbo, which is not auto-detected like the Turbolinks library is

Choose a reason for hiding this comment

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

@Judahmeek do we need to update this here as it doesn't seem to include turbo?

Screen Shot 2022-01-14 at 3 39 50 PM

Copy link
Member

Choose a reason for hiding this comment

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

we could allow for either string, but it's not totally required.

Copy link

@templeman15 templeman15 Jan 15, 2022

Choose a reason for hiding this comment

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

Yeah I was thinking turbo?: boolean

Or turbo: boolean | null or however it's actually defined.

I think it'd help increase visibility because my IDE only shows traceTurboLinks.

I'm speaking specifically about the d.ts file.

Copy link
Member

Choose a reason for hiding this comment

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

if we could easily just have the shorter traceTurbo, that's better for the long-term.

Copy link
Member

Choose a reason for hiding this comment

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

@Judahmeek, yes, we need to update the d.ts file.

Choose a reason for hiding this comment

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

@justin808 my interpretation of the code seems slightly different.

For Turbo to work I need:

turbo: true

To see the logging I need:

traceTurboLinks: true

Both have to be on for it to work and log with Turbo.

--

Turbolinks seems to work without opting into it. traceTurboLinks: true just prints to the logs in that scenario.

@justin808
Copy link
Member

CI is failing.

@@ -61,7 +61,8 @@ The best source of docs is the main [ReactOnRails.js](https://github.com/shakaco
/**
* Set options for ReactOnRails, typically before you call ReactOnRails.register
* Available Options:
* `traceTurbolinks: true|false Gives you debugging messages on Turbolinks events
* `traceTurbolinks: true|false` Gives you debugging messages on Turbolinks events
* `turbo: true|false` enables Turbo, which is not auto-detected like the Turbolinks library is
Copy link
Member

Choose a reason for hiding this comment

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

@Judahmeek, yes, we need to update the d.ts file.

document.addEventListener('turbolinks:render', reactOnRailsPageLoaded);
'turbolinks:before-visit and turbolinks:load.');
document.addEventListener('turbolinks:before-visit', reactOnRailsPageUnloaded);
document.addEventListener('turbolinks:load', reactOnRailsPageLoaded);
Copy link
Member

Choose a reason for hiding this comment

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

@Judahmeek did you test on Turbolinks 5?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did.

@Judahmeek
Copy link
Contributor Author

@justin808

CI was failing due to webpack-contrib/mini-css-extract-plugin#899.

I can put the fix commit in a separate PR if you'd prefer, but I'm expecting a new version from mini-css-extract-plugin's maintainers pretty quick since they already merged the fix.

Copy link
Member

@justin808 justin808 left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r1, 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @Judahmeek)


CHANGELOG.md, line 19 at r2 (raw file):

### Fixed
- Double rendering of components with using Turbo or Turbolinks. [PR 1421](https://github.com/shakacode/react_on_rails/pull/1421) by  [judahmeek](https://github.com/judahmeek).

and TS type for turbo option


node_package/src/clientStartup.ts, line 253 at r1 (raw file):

Previously, Judahmeek (Judah Meek) wrote…

I did.

👍

Copy link
Member

@justin808 justin808 left a comment

Choose a reason for hiding this comment

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

@Judahmeek up to you. After you make the changelog change, you can merge, squashing commits with a nice commit message.

Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @Judahmeek)

@Judahmeek
Copy link
Contributor Author

@justin808, @templeman15 says that this fix created a new problem with flashing content. We're exploring alternative solutions, such as #1425.

Also, I don't have permissions to merge PRs to master.

@Judahmeek Judahmeek closed this Jan 19, 2022
@Judahmeek Judahmeek deleted the judahmeek/turbolinks branch February 24, 2023 19:52
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.

Component is rendered twice when using Turbolinks
3 participants