Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the simplest way to share react components between projects? [closed]

I understand I can upload to npm and pull the modules between projects. Is there a similar way of doing that which is not public-facing code ( not visible to the entire world )?

Neither project is explicitly open source yet.

like image 296
JonaThan HaBer Avatar asked Oct 23 '18 19:10

JonaThan HaBer


People also ask

How many ways we can communicate between components in React?

I saw that the question is already answered, but if you'd like to learn more details, there are a total of 3 cases of communication between components: Case 1: Parent to Child communication. Case 2: Child to Parent communication. Case 3: Not-related components (any component to any component) communication.


2 Answers

Option 1: You can use npm and use private packages so they're not external facing. There are also artifactories and scoped packages that usually represent company-wide projects that can be public or private. See https://docs.npmjs.com/private-modules/intro and https://docs.npmjs.com/misc/scope.

Option 2: Essentially, you can develop projects with a flattened structure. You can then import various projects and/or components into other projects or folders. This is entirely dependent on your codebase and configuration. With this model though, a lot of times publishing to npm comes fairly naturally since each folder may be its own project with its own package.json.

Updated:

Option 3: Bit focuses on the composability of components from everything from the little things like a button to the actual view and app itself—each target is its own package. Overall, it's an opinionated, yet customizable framework that can enable quicker development, managed dependencies, and organized code.

Option 4: RushJS is a monorepo manager built by Microsoft that allows for flexibility of different kinds of apps and services utilizing pnpm underneath (as opposed to yarn and npm), which alleviates problems that stem from dependency issues.

like image 156
Ross Sheppard Avatar answered Oct 24 '22 04:10

Ross Sheppard


You could also upload them to a private git repo such a Github and then pull them in from there.

Ryanve has a nice example over here: https://stackoverflow.com/a/28729646/1592783

like image 23
Jack Avatar answered Oct 24 '22 05:10

Jack