【问题标题】:Does installing npm react react-dom in create react app is necessary?是否需要在 create react app 中安装 npm react react-dom ?
【发布时间】:2020-12-04 05:14:41
【问题描述】:

我阅读了reactstrap的文档,它指导我们安装npm包如下;

npm install --save bootstrap
npm install --save reactstrap react react-dom

我的问题是,是否需要安装 react 和 react-dom,这两个包不是默认包含在 create-react-app 中的吗?

【问题讨论】:

    标签: reactjs npm reactstrap


    【解决方案1】:

    是的,make时默认安装的

    npx create-react-app my-app
    

    如果您愿意,也可以使用 typescript 安装它

    npx create-react-app my-app --template typescript
    

    它还会添加@types/react-dom

    【讨论】:

    • 谢谢回答,你知道为什么 reactstrap 建议在它的文档中重新安装它吗?
    • 因为 reactstrap 中的对等依赖中的库
    【解决方案2】:

    是的!使用时默认包含在 node_modules 中

    npx create-react-app app-name
    

    但您也可以出于某种原因选择不使用它。然后你需要自己安装它们并添加你的项目启动文件。

    【讨论】:

    • 谢谢回答,你知道为什么 reactstrap 建议在它的文档中重新安装它吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-06
    • 2020-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-21
    相关资源
    最近更新 更多