D
D
Demigodd2019-04-27 10:55:53
JavaScript
Demigodd, 2019-04-27 10:55:53

How to remove prop type warning in React?

Used the Alert component from Element React.
https://elemefe.github.io/element-react/#/en-US/alert

<Alert title="" type="warning" description={
    <span>
      Click this button
      <Button>
        <span>Home</span>
      </Button>
    </span>
    } showIcon={true} />

This component has text written in the description attribute , but it only accepts string . But I also need tags.
The example above will give a warning in the console.
checkPropTypes.js:20 Warning: Failed prop type: Invalid prop `description` of type `object` supplied to `Alert`, expected `string`.
How it is possible to get rid of it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2019-04-27
@Demigodd

The description property must be passed a string, and you are passing an object.
An example of the correct use of the component:

<Alert title="Title string" description="Description string" showIcon />;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question