FAQ: PropTypes - PropTypes in Stateless Functional Components

This community-built FAQ covers the “PropTypes in Stateless Functional Components” exercise from the lesson “PropTypes”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Learn ReactJS: Part II

FAQs on the exercise PropTypes in Stateless Functional Components

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

It seems like there is a mistake in this exercise. There is no stateless functional component in the GuineaPigs file. There is a class declaration in it.

Reset the code and it will go back to normal. I’m answering this in case someone else gets stuck.

2 Likes
import React from 'react';

export const GuineaPigs = (props)=>{
    let src = this.props.src;
    return (
      <div>
        <h1>Cute Guinea Pigs</h1>
        <img src={src} />
      </div>
    );
}

GuineaPigs.propTypes = {
  src: React.PropTypes.string.isRequired
};

This will work

Not sure if I’m missing something here but this seems to be an error:

There is no class declaration, it’s a stateless function component?