Failed prop type: Component: prop type `props` is invalid;

Viewed 1164

I am getting warning as" Warning: Failed prop type: Component: prop type props is invalid; it must be a function, usually from the prop-types package, but received object"

my code is:

  const { history } = props.props
history.push('/next');

Component.propTypes = {
    props: {
        history: PropTypes.object,
    },
}

Component.defaultProps = {
    props: {
        history: PropTypes.object,
    },
}

My functionality working fine but getting this console error Can someone help me to resolve this warning?

1 Answers

You're using the value {} for props in propTypes, that's not allowed. You want shape:

Component.propTypes = {
  props: PropTypes.shape({
    history: PropTypes.object,
  }),
}
Related