admin管理员组

文章数量:1279242

I am wondering if it is possible to pop out a React ponent that has a whole Redux Store etc. into a new window with an iframe.

This is probably not possible to do but I wanted to see if anyone knew a way to achieve this?

The reason I want to popout the React ponent/application to a new window is so that I can keep the React App going while redirecting the user to another URL/Domain.

My React App/Component gets appended to a handlebars template using a <script> tag and a CDN to our bundled React App.

I am wondering if it is possible to pop out a React ponent that has a whole Redux Store etc. into a new window with an iframe.

This is probably not possible to do but I wanted to see if anyone knew a way to achieve this?

The reason I want to popout the React ponent/application to a new window is so that I can keep the React App going while redirecting the user to another URL/Domain.

My React App/Component gets appended to a handlebars template using a <script> tag and a CDN to our bundled React App.

Share Improve this question asked Oct 1, 2018 at 18:57 Henry LeeHenry Lee 1571 gold badge1 silver badge9 bronze badges 2
  • You could store the state of the app either locally using localStorage, or send it to the server. Then load the app normally in the iFrame and if it detects the stored version, load that it to continue from where it left off – Matthew Herbst Commented Oct 1, 2018 at 19:04
  • I don't think storing the state into local storage would solve everything. The reason is my React App/Component that is on the Zendesk template is a Chat Widget and I am using a SDK API to initialize a Chat. I don't think I can simply save this Chat object provided by the SDK into storage and read it from an iframe – Henry Lee Commented Oct 1, 2018 at 19:17
Add a ment  | 

1 Answer 1

Reset to default 8

You can use React Portal to open a new window and maintain it under React tree.

It's a semi-long post so check out this post.
Using a React 16 Portal to do something cool

You can open a new window, do what you need to do, and forward the user to a different URL, which won't affect your original window.

本文标签: javascriptPop out a react component into a new windowStack Overflow