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.
-
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
1 Answer
Reset to default 8You 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
版权声明:本文标题:javascript - Pop out a react component into a new window - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741303970a2371258.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论