简体   繁体   中英

Module not found: Can't resolve '@material-ui/core/RaisedButton' in React

I am getting the error

Module not found: Can't resolve '@material-ui/core/RaisedButton' in 'C:\\wamp64\\www\\multi-step-form\\src\\components'

I have installed @material-ui/core

My imports in this file are:

import React, { Component } from 'react';
import { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';
import AppBar from '@material-ui/core/AppBar';
import TextField from '@material-ui/core/TextField';
import RaisedButton from '@material-ui/core/RaisedButton';

and the dependencies in package.json looks like:

 "dependencies": {
    "@material-ui/core": "^3.9.2",
    "normalize.css": "^8.0.0",
    "react": "^16.5.2",
    "react-dom": "^16.5.2",
    "react-scripts": "1.1.5"
  },

Can somebody check?

There is no RaisedButton button component in Material-UI. Instead just import Button and use the prop variant of value contained to have it raised. Don't use a variant of value raised as it's deprecated, use contained :

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

// ...

<Button variant="contained">
  Default
</Button>

Here is an example in action.

Hopefully that helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM