Visual Studio C # ASP 내의 React 앱에서 Material-UI를 사용할 수 없습니다. NET Core 웹 애플리케이션

폴 미란다

React 및 Redux 템플릿을 사용하여 새로운 .NET Core 웹 애플리케이션을 만들었습니다. ClientApp 폴더 (반응 프로젝트가있는 폴더)에 Material-UI 라이브러리를 설치하고 라이브러리에서 구성 요소를 가져올 때 앱에서 다음 오류가 발생한다는 점을 제외하면 모든 것이 잘 작동합니다.

TypeError: __WEBPACK_IMPORTED_MODULE_0_react___default.a.createContext is not a function

내 package.json은 다음과 같습니다.

{
  "name": "Evento",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^4.11.0",
    "bootstrap": "^3.4.1",
    "react": "^16.0.0",
    "react-bootstrap": "^0.31.5",
    "react-dom": "^16.0.0",
    "react-redux": "^5.0.6",
    "react-router-bootstrap": "^0.24.4",
    "react-router-dom": "^4.2.2",
    "react-router-redux": "^5.0.0-alpha.8",
    "react-scripts": "1.0.17",
    "redux": "^3.7.2",
    "redux-thunk": "^2.2.0",
    "rimraf": "^2.6.2"
  },
  "scripts": {
    "start": "rimraf ./build && react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

머티리얼 UI 버튼을 가져 오려는 컴포넌트는 다음과 같습니다.

import React, { Component } from 'react';
import { Button } from '@material-ui/core';

export default class Main extends Component {
    render() {
        return (
            <div>Hello world!</div>
        );
    }
}

이 문제가 발생하는 이유와 해결 방법은 무엇입니까?

Squillman

React를 업데이트해야합니다. v16.0.0은 머티리얼 UI 4.11에 비해 너무 오래되었습니다. React 및 React DOM을 최소 16.8.0으로 업데이트해야합니다.

npm update react react-dom

Webpack이 새 버전을 다시 번들 할 수 있도록 나중에 앱을 다시 시작해야합니다.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관