Provide better API for opening in new tab#1743
Closed
Sharcoux wants to merge 1 commit intonecolas:masterfrom
Closed
Provide better API for opening in new tab#1743Sharcoux wants to merge 1 commit intonecolas:masterfrom
Sharcoux wants to merge 1 commit intonecolas:masterfrom
Conversation
Opening link in a new tab is something quite common on web nowadays. This use case should be handled by react-native-web. Currently, the only solution is [described here](necolas#162). And we can all agree I think that this is not what we could think as a satisfying solution. Here is my proposal. It should be transparent for native and provide the ability for web.
ElForastero
reviewed
Nov 11, 2020
| const open = (url: string, target?: '_blank') => { | ||
| if (canUseDOM) { | ||
| window.location = new URL(url, window.location).toString(); | ||
| window.open(url, target).focus(); |
There was a problem hiding this comment.
window.open() is different from window.location assignment.
They are not interchangeable. 🤔 This will open a new tab.
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.
Opening link in a new tab is something quite common on web nowadays. This use case should be handled by react-native-web.
Currently, the only solution is described here. I think that we can all agree that this is not very satisfying.
Here is my proposal. It should be transparent for native and provide the ability for web.