K
K
Konstantin Chuykov2020-07-09 23:35:19
git
Konstantin Chuykov, 2020-07-09 23:35:19

How to combine two large react applications from different reps?

Good afternoon, ladies and gentlemen! There was a serious question over which I struggle the fourth day.
There are two repositories, one is laravel + react (custom webpack) and the other is purely react (CRA).
You need to add the second application to the first as a component (with the ability to simply update the component and continue developing in the second turnip).

What has already been tried?
- I did a regular git clone, but there was a problem with relative paths.
- I did the build via rollup, but some components were not included in the bundle, due to dynamic import
- I made a compiled copy with babel and published the npm package. But when I connect, I get an error:

Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.


It's important to note that the second application ( https://github.com/chuikoffru/rrbe) uses lazy loading with loadable-component, relative paths, and hooks.
npm run pack
npm run pack - делает бандл с помощью rollup
npm run pack-widget - делает клон es5 в dist

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Robur, 2020-07-10
@chuikoffru

well, there are two options:
- have two react applications on the page, initializing them in different containers
- lead to the same architecture and structure to start with.
the second implies that it is necessary to redo it so that the assembly is the same for all and the same versions of the libraries are used, at least react and all "global" things, such as routing, gql if any, etc. anything that has a global state or uses a react context.
connect as source code - it will be easier to change what needs to be changed, you do not need a separate module.
Naturally, if you want to combine applications at the source code level, then with a high probability this code and assembly will have to be redone either in the first or in the second.

L
Lynatik001, 2020-07-10
@Lynatik001

moleculer mb? integrates different applications. even if they are on different machines.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question