4/4 PropTypes in Stateless Functional Components ISSUE


#1

https://www.codecademy.com/courses/react-102/lessons/proptypes/exercises/proptypes-stateless?action=lesson_resume&link_content_target=interstitial_undefined

I’m not sure what’s wrong, but this is the error I’m getting: expected undefined to equal [Function

And that’s the entirety of the error message. What am I doing wrong?

import React from 'react';

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

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

#2

The error message is an exception, not an SCT error message so there is something amiss with the JS code.

Not sure the above lines belong in this compnent. Try running without it and see what happens.

(The vote I gave you is for posting a link. Thank you.)


#3

I figured it out. I was adding a propType of “message” when it should have been “src”. Silly mistake on my part!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.