Skip to content

Provide better API for opening in new tab#1743

Closed
Sharcoux wants to merge 1 commit intonecolas:masterfrom
Sharcoux:patch-2
Closed

Provide better API for opening in new tab#1743
Sharcoux wants to merge 1 commit intonecolas:masterfrom
Sharcoux:patch-2

Conversation

@Sharcoux
Copy link
Copy Markdown

@Sharcoux Sharcoux commented Sep 18, 2020

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.

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.
This was referenced Sep 18, 2020
const open = (url: string, target?: '_blank') => {
if (canUseDOM) {
window.location = new URL(url, window.location).toString();
window.open(url, target).focus();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

window.open() is different from window.location assignment.

They are not interchangeable. 🤔 This will open a new tab.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is indeed the goal

@necolas necolas added this to the 0.15 milestone Dec 8, 2020
@necolas necolas closed this in b7b3830 Feb 12, 2021
rnike pushed a commit to VeryBuy/react-native-web that referenced this pull request Sep 13, 2022
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.

3 participants