React PropTypes

React PropTypes
0.0 0

#1

Tell us what’s happening:
My code doesn’t pass the test. Also i don’t understand how to use this PropsTypes…?

Your code so far


import React, { PropTypes } from 'react';

const Items = (props) => {
  return <h1>Current Quantity of Items in Cart:

  {props.quantity}</h1>
};

// change code below this line
Items.PropTypes = {
  quantity: PropTypes.number.isRequired
}
// change code above this line

Items.defaultProps = {
  quantity: 0
};

class ShoppingCart extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return <Items />
  }
};

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/use-proptypes-to-define-the-props-you-expect


#2

It’s Items.propTypes (note the capitalisation)

The rest is right as far as I can see though I’m away from my pc so sort of winging it here

It may seem stupid that one use is not capitalised and the other is, but one is a member of an object and the other is the name of a class