Open
Conversation
c5593cc to
d13289d
Compare
443c0b7 to
7ba2858
Compare
7ba2858 to
513e7cd
Compare
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
513e7cd to
a584810
Compare
a584810 to
3ae03af
Compare
3ae03af to
c299b6a
Compare
c299b6a to
a4b4e7a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Plugin features when merged
Image,LinkoruseRouter()What are "React Portability Patterns"?
Watch this video to know all about the why and how, as explained by Jack Herrington:
What do portability patterns solve?
Typically, in Universal React Setups you had to choose between Next.js or Expo for Web to build the web version of your app. The reason is that the Next.js router and components like Link are pretty incompatible.
e.g. just slapping
.web.tsxon a Next.js specific version ofLink.tsxwould work great in Next.js... but break the screen or component when opening it with Expo for Web, since using any of the Next.js router hooks or components expect its content to be mounted as well. Which is never the case when rendering web with Expo. You might, for example, have experienced similar issues when trying to render components in Storybook.How do portability patterns work?
The trick is to not split implementations on the web or native level, but on the rendering framework level.
The only real way to do this, as far as I know, was to use React's context API to:
.types.tsfileLinkcomponent &useRouter()hook that each implement these same typesLink&routerobject in contextLink&routerobject in contextuseRouter()hook use therouterobject from contextLinkcomponent pass props to theLinkcomponent from contextuseRouter()&LinkcomponentsWhat do portability patterns enable?
Well, to take things further and with the right effort, you could theoretically apply these same steps to:
Whether you want to reuse components and screens in Expo, Next, Remix or a smart fridge, if you have enough time and the right docs at hand, the possibilities are almost endless 👀
Enjoy!