Skip to content

Refactor Links.tsx to use react islands - #3841

Merged
OllysCoding merged 2 commits into
mainfrom
olly/links-to-islands
Jan 18, 2022
Merged

OllysCoding merged 2 commits into
mainfrom
olly/links-to-islands

Conversation

@OllysCoding

@OllysCoding OllysCoding commented Jan 18, 2022 •

Copy link
Copy Markdown
Contributor

What does this change?

Refactors Links.tsx to use react islands

To achieve this I had to move the previously global state userId to within the component. We only want to request the user profile on the client, creating the MyAccount component allowed us to ensure it only requests the profile there.

I also generally refactored the component around how it hydrates. We can do this because now that this react component renders as it's own island, it's no longer affecting renders for anything else.

Inspiration for this credited to #3747 (thanks @oliverlloyd)

Note: This will introduce a duplicate call to the profile endpoint as Discussion also makes use of the App.tsx call we refactored away from. This duplication is only temporary as once discussion is migrated to use Islands, SWR will cache any duplicate calls. You can track progress on discussion migration in #3839

Why?

This helps with our general goal of migrating away from and deleting App.tsx, but also unblocks #3832, which is having a hydration problem which is solved by islands.

Testing

I've tested this locally, however since logging in does not work locally, we should also test on CODE to ensure functionality

@github-actions

github-actions Bot commented Jan 18, 2022 •

Copy link
Copy Markdown

Size Change: -14.6 kB (-1%)

Total Size: 2.59 MB

Filename Size Change
dotcom-rendering/dist/413.js 0 B -4.24 kB (removed) 🏆
dotcom-rendering/dist/413.legacy.js 0 B -4.35 kB (removed) 🏆
dotcom-rendering/dist/790.js 0 B -2.14 kB (removed) 🏆
dotcom-rendering/dist/790.legacy.js 0 B -2.19 kB (removed) 🏆
dotcom-rendering/dist/frontend.server.js 1.82 MB +338 B (0%)
dotcom-rendering/dist/islands.js 7.24 kB +9 B (0%)
dotcom-rendering/dist/islands.legacy.js 8.01 kB +13 B (0%)
dotcom-rendering/dist/react.js 136 kB -1.03 kB (-1%)
dotcom-rendering/dist/react.legacy.js 142 kB -1.02 kB (-1%)
ℹ️ View Unchanged
Filename Size
dotcom-rendering/dist/195.js 1.11 kB
dotcom-rendering/dist/195.legacy.js 1.23 kB
dotcom-rendering/dist/272.js 8.6 kB
dotcom-rendering/dist/327.js 4.46 kB
dotcom-rendering/dist/327.legacy.js 4.47 kB
dotcom-rendering/dist/331.js 16.2 kB
dotcom-rendering/dist/331.legacy.js 16.4 kB
dotcom-rendering/dist/343.js 1.63 kB
dotcom-rendering/dist/343.legacy.js 1.71 kB
dotcom-rendering/dist/348.js 4.02 kB
dotcom-rendering/dist/348.legacy.js 4.12 kB
dotcom-rendering/dist/39.js 4.05 kB
dotcom-rendering/dist/39.legacy.js 4.21 kB
dotcom-rendering/dist/400.js 21.5 kB
dotcom-rendering/dist/400.legacy.js 21.5 kB
dotcom-rendering/dist/460.legacy.js 6.75 kB
dotcom-rendering/dist/468.legacy.js 3.09 kB
dotcom-rendering/dist/597.js 5.36 kB
dotcom-rendering/dist/597.legacy.js 5.52 kB
dotcom-rendering/dist/602.js 4 kB
dotcom-rendering/dist/602.legacy.js 4.11 kB
dotcom-rendering/dist/624.js 3.58 kB
dotcom-rendering/dist/624.legacy.js 3.7 kB
dotcom-rendering/dist/639.js 4.27 kB
dotcom-rendering/dist/639.legacy.js 4.38 kB
dotcom-rendering/dist/965.js 2.16 kB
dotcom-rendering/dist/965.legacy.js 2.23 kB
dotcom-rendering/dist/atomIframe.js 1.87 kB
dotcom-rendering/dist/atomIframe.legacy.js 2.14 kB
dotcom-rendering/dist/bootCmp.js 7.39 kB
dotcom-rendering/dist/bootCmp.legacy.js 10.9 kB
dotcom-rendering/dist/braze-web-sdk-core.js 36.1 kB
dotcom-rendering/dist/braze-web-sdk-core.legacy.js 36.1 kB
dotcom-rendering/dist/CalloutBlockComponent.js 4.14 kB
dotcom-rendering/dist/CalloutBlockComponent.legacy.js 4.46 kB
dotcom-rendering/dist/cmp.js 7.51 kB
dotcom-rendering/dist/coreVitals.js 4.03 kB
dotcom-rendering/dist/coreVitals.legacy.js 4.33 kB
dotcom-rendering/dist/DocumentBlockComponent.js 566 B
dotcom-rendering/dist/DocumentBlockComponent.legacy.js 596 B
dotcom-rendering/dist/dynamicImport.js 2.99 kB
dotcom-rendering/dist/dynamicImport.legacy.js 3.29 kB
dotcom-rendering/dist/embedIframe.js 1.88 kB
dotcom-rendering/dist/embedIframe.legacy.js 2.14 kB
dotcom-rendering/dist/ga.js 3.88 kB
dotcom-rendering/dist/ga.legacy.js 4.14 kB
dotcom-rendering/dist/guardian-braze-components-banner.js 9.57 kB
dotcom-rendering/dist/guardian-braze-components-banner.legacy.js 9.58 kB
dotcom-rendering/dist/guardian-braze-components-end-of-article.js 6.56 kB
dotcom-rendering/dist/guardian-braze-components-end-of-article.legacy.js 6.57 kB
dotcom-rendering/dist/InteractiveBlockComponent.js 2.95 kB
dotcom-rendering/dist/InteractiveBlockComponent.legacy.js 3.09 kB
dotcom-rendering/dist/InteractiveContentsBlockComponent.js 1.87 kB
dotcom-rendering/dist/InteractiveContentsBlockComponent.legacy.js 1.95 kB
dotcom-rendering/dist/MapEmbedBlockComponent.js 1.87 kB
dotcom-rendering/dist/MapEmbedBlockComponent.legacy.js 1.93 kB
dotcom-rendering/dist/MostViewedFooterData.js 6.27 kB
dotcom-rendering/dist/MostViewedFooterData.legacy.js 6.37 kB
dotcom-rendering/dist/newsletterEmbedIframe.js 1.83 kB
dotcom-rendering/dist/newsletterEmbedIframe.legacy.js 2.1 kB
dotcom-rendering/dist/OnwardsLower.js 9.7 kB
dotcom-rendering/dist/OnwardsLower.legacy.js 9.91 kB
dotcom-rendering/dist/OnwardsUpper.js 14.1 kB
dotcom-rendering/dist/OnwardsUpper.legacy.js 14.4 kB
dotcom-rendering/dist/ophan.js 7.18 kB
dotcom-rendering/dist/ophan.legacy.js 7.38 kB
dotcom-rendering/dist/relativeTime.js 2.41 kB
dotcom-rendering/dist/relativeTime.legacy.js 2.68 kB
dotcom-rendering/dist/RichLinkComponent.js 3.25 kB
dotcom-rendering/dist/RichLinkComponent.legacy.js 3.29 kB
dotcom-rendering/dist/sentry.js 676 B
dotcom-rendering/dist/sentry.legacy.js 688 B
dotcom-rendering/dist/sentryLoader.js 4.74 kB
dotcom-rendering/dist/sentryLoader.legacy.js 7.71 kB
dotcom-rendering/dist/shimport.js 2.75 kB
dotcom-rendering/dist/shimport.legacy.js 2.76 kB
dotcom-rendering/dist/SignInGateMain.js 1.82 kB
dotcom-rendering/dist/SignInGateMain.legacy.js 1.85 kB
dotcom-rendering/dist/VideoFacebookBlockComponent.js 1.88 kB
dotcom-rendering/dist/VideoFacebookBlockComponent.legacy.js 1.93 kB
dotcom-rendering/dist/VineBlockComponent.js 575 B
dotcom-rendering/dist/VineBlockComponent.legacy.js 591 B
dotcom-rendering/dist/YoutubeBlockComponent.js 2.57 kB
dotcom-rendering/dist/YoutubeBlockComponent.legacy.js 2.7 kB

compressed-size-action

@oliverlloyd oliverlloyd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A minor comment on what to do if there's an error but not a blocker

Comment thread dotcom-rendering/src/web/components/Links.importable.tsx Outdated
@OllysCoding
OllysCoding merged commit 72f37b0 into main Jan 18, 2022
@OllysCoding
OllysCoding deleted the olly/links-to-islands branch January 18, 2022 15:39
@OllysCoding

Copy link
Copy Markdown
Contributor Author

@jamesgorrie

Copy link
Copy Markdown
Contributor

part of #3629

@OllysCoding
OllysCoding restored the olly/links-to-islands branch January 20, 2022 17:28
@OllysCoding
OllysCoding deleted the olly/links-to-islands branch January 20, 2022 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants