Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The prop `children` is marked as required in `Button`, but its value is `undefined`

I am trying to convert an older Material UI implementation. The Docs are bit laggy.

I get this error. The docs say

Name Type Default Description

children * node The content of the button.

What does this mean and what do I have to put in my code?

<Button
  variant="raised"
  color="primary"
  className={classes.Button}
  label={this.state.buttonLabel}
  onClick={this.handleClick}
>
</Button>
like image 648
Axwack Avatar asked May 07 '18 13:05

Axwack


2 Answers

"children" are what is between the tags:

<Button>we are the children</Button>

Because you don't pass anything - it's undefined. To fix error just add something that React can render, like string:

<Button
  variant="raised"
  color="primary"
  className={classes.Button}
  label={this.state.buttonLabel}
  onClick={this.handleClick}
>
  My Button
</Button>;
like image 110
Tomasz Mularczyk Avatar answered Nov 16 '22 02:11

Tomasz Mularczyk


Looks like they removed the label property and moved it to the children prop.

So you have to put it between the tags e.g.

<Button> here comes the label </Button>

You can always check the demos for the Components. See here

like image 39
Murat Karagöz Avatar answered Nov 16 '22 00:11

Murat Karagöz