0

In react component there is nested object in propTypes which works fine.

UserCard.propTypes = {
  name: PropTypes.string,
  customer: PropTypes.shape({
    email: PropTypes.string,
    phoneNumber: PropTypes.string,
  }),
};

Looking for solution to assign defaultProps for the nested objects. It seems to be current implementation is not valid solution.

UserCard.defaultProps = {
  name: 'No Name',
  email: 'No Email',
  phoneNumber: '0',
};

1 Answer 1

1

It should look like this:

UserCard.defaultProps = {
  name: 'No name',
  customer: {
      email: 'No email',
      phoneNumber: '0',
  },
};
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.