Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't use "startIcon" & "endIcon" from <Button/> API of Material-UI

Here is my simple React code for a single component but it keep throwing the same warning every-time I checked. Even when copy and past the example still same warning and the icon is nowhere to be seen. Please help!

Link

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


class AddWorkButton extends Component {
    constructor(props) {
        super(props);
        this.state = {  }
    }
    render() { 
        return (  
            <React.Fragment>
                <Button
                        variant="contained"
                        color="secondary"
                        startIcon={<AddIcon/>}
                >
                    TEST
                </Button>
            </React.Fragment>
        );
    }
}

export default AddWorkButton;
like image 730
Đức Quỳnh Nguyễn Avatar asked Oct 03 '19 09:10

Đức Quỳnh Nguyễn


2 Answers

I got the same error.

The problem on my side was that react-script start was already running when I updated the Material-UI package to 4.5.

After I have restarted the react-script start everything just started to work.

like image 177
Mark Kalinovits Avatar answered Oct 22 '22 18:10

Mark Kalinovits


  <Button variant="contained" color="primary" >
          Send <ArrowForwardIcon /> </Button>

Not sure which way is the correct but I got it working this way,

like image 2
kapil Avatar answered Oct 22 '22 17:10

kapil