Javascript React Material UI和Hello Wold测试中的钩子调用错误无效

Javascript React Material UI和Hello Wold测试中的钩子调用错误无效,javascript,reactjs,react-native,material-ui,Javascript,Reactjs,React Native,Material Ui,我想用React和materialui启动一个项目。首先,我想做一个最简单的Hello World。最简单的基于一个全新的UbuntuOS的官方文档,但我得到了错误!我的代码是: App.js package.json 我没有在依赖项中看到materialize,请尝试在应用程序根目录中使用npm install@material ui/core重新安装。我没有在依赖项中看到materialize,请尝试在应用程序根目录中使用npm install@material ui/core重新安装 np

我想用
React
materialui
启动一个项目。首先,我想做一个最简单的Hello World。最简单的基于一个全新的
Ubuntu
OS的官方文档,但我得到了错误!我的代码是:

App.js package.json
我没有在依赖项中看到materialize,请尝试在应用程序根目录中使用npm install@material ui/core重新安装。

我没有在依赖项中看到materialize,请尝试在应用程序根目录中使用npm install@material ui/core重新安装

npm install @material-ui/core
你必须包括图书馆


您必须包含库。

您还没有使用钩子发布任何代码。您确定错误不是源于其他组件吗?或者,正如错误所说,您可能有多个版本的React,比如material ui可能正在使用一个版本,而您的应用程序正在使用另一个版本。如果您执行
npm ls React
,这将帮助您确定是否已安装了两个版本的React。您没有使用挂钩发布任何代码。您确定错误不是源于其他组件吗?或者,正如错误所说,您可能有多个版本的React,例如material ui可能正在使用一个版本,而您的应用程序正在使用另一个版本。如果您执行
npm ls React
,这将帮助您确定是否已安装两个版本的React。
import React from 'react';

import Button from '@material-ui/core/Button';

function SMSAuth(){
    return(
        <Button variant="contained" color="primary">
            Hello World
        </Button>
    );
}

export default SMSAuth
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
{
  "name": "web-ui",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

npm install @material-ui/core