Conceptual issues. I have two projects running on two different React services. Many components can be shared between the two projects. How should I set this up so that I can have a "live" project with shared components, and multiple projects can use these components in real time. Through searching, I learned that it can be achieved through npm packages and installed, but will this eliminate real-time performance? Is there a way that components can be developed as independent projects and multiple projects can be developed together.
P粉9707363842023-09-21 13:43:59
To create a shared component, we can create another repository on Git and convert it into a library. You can then use this as a package for your own share-c.
Here are a few steps you can try...
Add the private git repository as a dependency.
Specify the branch below
git https://github.com/username/repository.git#branch-name
Open your package.json file and add dependencies like this.
"dependencies": { "packageName": "git https://github.com/username/repository.git#branch-name" }
Run npm install
It should be helpful...