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

Draft: fix: conditionally import react navigation #3954

Closed
wants to merge 1 commit into from

Conversation

tjaniczek
Copy link
Collaborator

Fixes #3952

Summary

Unfortunately Webpack won't allows us to import missing export via ES6. Dynamic imports are a no-go as well. They're async and since we want to import hook we end up with Promise<useLinkTools>. This would break rules of hooks since we'd have a conditional hook rendered (before and after async import).

The only solution I found is to import the whole package as CommonJS. This won't break the rules since it's sync. It will import once and then only one hook will be returned.

Test plan

Example app does not throw an error anymore on either v6 or v7

@DimitarNestorov
Copy link
Contributor

Using CommonJS also isn't ideal because bundlers do not do tree shaking

@github-actions
Copy link

The mobile version of example app from this branch is ready! You can see it here.

@tjaniczek tjaniczek changed the title fix: conditionally import react navigation Draft: fix: conditionally import react navigation Jun 27, 2023
@tjaniczek tjaniczek closed this Jun 27, 2023
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.

export 'useLinkTools' (imported as 'useLinkTools') was not found in '@react-navigation/native'
2 participants