Karan Patokar
Karan Patokar

Reputation: 503

Failed prop type: The prop `id` is marked as required in `FormattedMessage`, but its value is `undefined`

I am getting this error in my whole project and I don't know what to do about that. It is giving the error even when the component like below is not present in the component.

<FormattedMessage {...messages.forexample} />

Mobx, react-intl is being used here.

New Edit

The message I am paassing is in the format

example: {
       id: "app.components.cartItem.example",
       defaultMessage: 'Items in your cart',
   }

Upvotes: 2

Views: 1763

Answers (1)

Ryan
Ryan

Reputation: 27

In your FormattedMessage component, you need to set a default value on id

FormattedMessage.defaultProps = {
 id: 0
}

Upvotes: 2

Related Questions