如何将 GitHub 中的 React 应用作为组件导入到新的 React 应用中?

How to import react app from GitHub as a component to new react app?

如何从我的 GitHub 帐户 导入 React 应用程序作为新 React 应用程序的组件?

例如,我构建了一个 NavBar 的 React 应用程序并将其上传到 GitHub。我想将此 NavBar 应用程序作为组件导入到新 React 项目的 header 组件中。

尝试按以下方式使用 npm 安装包:

npm install --save your_repo_url/master

试试这个:

npm install git://github.com/username/repo.git#branch-name

yarn add git://github.com/username/repo.git#branch-name

// Example
yarn add git://github.com/denvash/react-pagination-example.git#master

然后根据repo路径导入,例如:

import Pagination from 'react-pagination/src/components/Pagination.react'