Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using mobx between window and iframe #1644

Closed
sophister opened this issue Jul 20, 2018 · 6 comments
Closed

using mobx between window and iframe #1644

sophister opened this issue Jul 20, 2018 · 6 comments

Comments

@sophister
Copy link

sophister commented Jul 20, 2018

A question

I have a store in top window, and I passed store into an iframe which is same origin.

when I change store properties in top window, my React component within iframe do not update.

does mobx support using with iframes?

thx

@mattruby
Copy link
Member

mattruby commented Jul 20, 2018 via email

@sophister
Copy link
Author

@mattruby I've created two pages with codesandbox.io, this is parent page and this is iframed page . But iframed page does not work as expected. maybe something went wrong in such situation.

in top page, I've expose mobx and store objects to top, so that I can access them within iframe.

in iframed page, I try to access two mobx.autorun function: one is just import {autorun} from mobx, the second is window.top.mobx.autorun from top window.

when I update store in top page, only the second autorun called.

@mweststrate
Copy link
Member

@sophister it is because you are using two different instances of MobX, which both have their own internal state. Instead of having mobx as a dependency in the framed page, you should pass mobx from the parent to the framed page (not that this is possible only if they are on the same domain, otherwise browser security will prevent this)

@sophister
Copy link
Author

@mweststrate get it, thx a lot

@umbrellaZwl
Copy link

i have the same question, are you solved the problem by the method?

@danielkcz
Copy link
Contributor

@umbrellaZwl You need to elaborate on what you have tried and did not work for you. Also, please don't comment on old & closed issues as only a few people will see that. Open a new issue with all details of your problem.

@mobxjs mobxjs locked as resolved and limited conversation to collaborators May 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants