Share React components between projects
P粉225961749
P粉225961749 2023-09-21 00:01:52
0
1
677

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粉225961749
P粉225961749

reply all(1)
P粉970736384

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...

  1. Add the private git repository as a dependency.

  2. Specify the branch below

    git https://github.com/username/repository.git#branch-name

  3. Open your package.json file and add dependencies like this.

    "dependencies": { "packageName": "git https://github.com/username/repository.git#branch-name" }

  4. Run npm install

It should be helpful...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template