freeCodeCamp Challenge Guide: Use Default Props

Use Default Props

Problem Explanation

This challenge has you declaring a default prop for the ShoppingCart component

const ShoppingCart = props => {
  return (
      <h1>Shopping Cart Component</h1>

To declare a default prop, the syntax to be followed is

itemName.defaultProps = {
  prop-x: value,
  prop-y: value

Following the Syntax, the following code should be declared below the given code

ShoppingCart.defaultProps = {
  items: 0

This declares a prop named β€˜items’ with the value of β€˜0’ .