Files
Randell Dawson 1494a50123 fix(guide): restructure curriculum guide articles (#36501)
* fix: restructure certifications guide articles
* fix: added 3 dashes line before prob expl
* fix: added 3 dashes line before hints
* fix: added 3 dashes line before solutions
2019-07-24 13:29:27 +05:30

794 B

title
title
Review Using Props with Stateless Functional Components

Review Using Props with Stateless Functional Components


Hints

Hint 1

A functional(a.k.a. stateless) component is just a plain javascript function which takes props as an argument and returns a react element.

Hint 2

Use Component.defaultProps to set default props.

Hint 3

Use Component.propTypes to set props types.


Solutions

Solution 1 (Click to Show/Hide)
const Camper = props => <p>{props.name}</p>;

Camper.defaultProps = {
  name: "CamperBot"
};

Camper.propTypes = {
  name: PropTypes.string.isRequired
};