This is a migrated thread and some comments may be shown as answers.

Invalid prop children warning with Button

1 Answer 788 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 06 Sep 2018, 06:29 PM
Warning: Failed prop type: Invalid prop `children` supplied to `Button`.
    in Button (created by App)
    in App

How can I resolve this warning? It seems to dislike anything other than a text node.

class SimpleThing extends React.PureComponent {
  render() {
    return <span>Thing</span>;
  }
}
 
class App extends React.Component {
    render(){
        return(
            <div class="example-wrapper">
                <div className="example-col">
                  <p>Button</p>
                  <Button><SimpleThing /></Button>
                </div>
            </div>
        )
    }
}

https://stackblitz.com/edit/react-m5avfp?file=app%2Fmain.js

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 07 Sep 2018, 06:53 AM
Hello, Ryan,

Thank you for the example.

The PropType check is making this warning as the type is currently element or string:

static propTypes = {
    children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element), PropTypes.string]),

I will check if there is a specific reason why another component is not a valid prop and we will update the PropTypes accordingly.

Please have in mind that this is only a type warning in development mode and it should not cause JS errors.

Regards,
Stefan
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Ryan
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or