benmvp / ama

Ask me anything!
https://github.com/benmvp/ama/issues?q=is%3Aissue+is%3Aclosed
3 stars 3 forks source link

Embedding a Redux connected component dynamically through JSONP #19

Closed SandhyaGiri closed 5 years ago

SandhyaGiri commented 6 years ago

Hi Ben,

How are you doing? I attended your React workshop in Feb 2018.

Currently I am developing an application where a certain part of the page needs to be rendered from a different application using JSONP callback. Incidentally, the hosting application is built in React with redux store. Also, the second application which renders a part of the page, is also a React application with redux store. These applications are hosted in different application servers and don't share code.

We are facing an issue because of both applications using redux store. To be exact, we are seeing the following error

image

Provider does not support changing store on the fly. It is most likely that you see this error because you updated to Redux 2.x and React Redux 2.x which no longer hot reload reducers automatically. See https://github.com/reactjs/react-redux/releases/tag/v2.0.0 for the migration instructions.

We happened to learn about "replaceReducer" for the redux store. But using this would mean that any further action triggered from the hosting application will be routed to the new reducer - which will not be handling those action types.

Though this can be achieved via Iframe, we wanted to see if the JSONP solution to render the page from different application works. It would be helpful if you can point us in the right direction.

Thanks, Sandhya

benmvp commented 6 years ago

Hi @SandhyaGiri! I'm trying to do my best to understand the problem. So you have two separate applications on the page, right? But they are sharing the same redux store?

SandhyaGiri commented 6 years ago

Hi Ben,

Yes technically second application is trying to create a new store with different set of reducers. And this is getting blocked.

Thanks, Sandhya