Rahul
Rahul

Reputation: 265

How can i open a component in new Tab in react.js?

I have a dropdown which will a client list. Based on what i select in the dropdown i want to open a new tab for that particular client. Is there any way to do it? I tried window.open(), while it works but it appends URl to http://localhost:3000/[object%20Object]. I dont what object to get appended in the URL. TIA

Upvotes: 3

Views: 15248

Answers (1)

Dacre Denny
Dacre Denny

Reputation: 30360

The window.open() method accepts a URL, so passing a component/javascript in the way that you require is not possible.

Consider setting up a route, say /popup-tableau that exclusively renders the <Tableau /> component, and then call:

window.open('/popup-tableau')

The idea here is that your application will open the new window, and a second instance of your application will be started (inside the new window), and directed to the route /popup-tableau which will display the <Tableau /> component in the way you require.

Upvotes: 6

Related Questions