4/4 PropTypes in Stateless Functional Components ISSUE


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 (
      <h1>Cute Guinea Pigs</h1>
      <img src={src} />

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

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.)

1 Like

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

1 Like

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