-
-
Notifications
You must be signed in to change notification settings - Fork 917
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
How to send data between portal and child? #181
Comments
Did you take a look at https://github.com/me-12/single-spa-portal-example? In this example project you can click on the "global increment" or "global decrement" button in either the react app or the angular5 app. Each click will send the click event to the other app. |
@me-12 I saw that button. But it's used to synchronize the data between two apps. For now, like in app1, click submit button to submit a form. I'm wondering if the portal can get this data and transfer it to the app2? Or even if the portal decides not to transfer data, app2 will never receive it. I look some docs about single-spa, but can't find if he can do this. |
That button does not synchronize the data, it does just send an event which the other app receives and processes. If you want to send some form data from app1 to app2, you need to dispatch an event from app1 which has some payload. And in app2 you will receive this event inclusive payload. Then you can process this data in any way you like. For example:
Have a look at the redux documentation to understand how this works in detail https://redux.js.org/ |
@me-12 thanks for jumping in and helping out with this one. I agree that passing custom props is a good way to share data between applications. @lyzJoey Does me-12's response help explain how you can get redux actions to dispatch between applications? The mount lifecycle function is given Also, check out #112 and #142 for previous discussion about inter-app communication and redux. |
@joeldenning could you make an example of how to get the customProps from my child app, because, I can se using the react explorer that I have my custom prop, but I don't really know how to get and use the value |
Similar issue here I'm creating a global store for intra-app communication using a Redux store created in the I'm using The issue is that I need to access the data from the Do you have an idea of how to make the |
@JeanOsorio please see https://single-spa.js.org/docs/building-applications.html#custom-props Let us know if you have any other questions |
I check the single-spa-portal-example sample code. We can use the redux to share the data between portal and child app. It's like the copy of the data between child app. For now, I want to send the data to another child app after triggering the event like click the submit button. Can I do this using single-spa?
The text was updated successfully, but these errors were encountered: