How and where to delete the original GuineaPigs as per the instruction?


#1

Hi all,
I am unable to understand the instruction. I rewritten the code in the form of stateless functional component in GuineaPigs.js file. I don’t know where to delete the original GuineaPigs class. Please help me out!

Thanks in advance
Here is the link to my code
https://www.codecademy.com/en/courses/react-102/lessons/stateless-functional-components/exercises/stateless-functional-component-props?action=lesson_resume&link_content_target=interstitial_lesson


#2

I’m stuck on this one as well. I also can’t get to your code. My code right now is just;

var React = require('react');
var ReactDOM = require('react-dom');

var GuineaPigs = React.createClass({
  render: function () {
    return <h1>{this.props.title}</h1>;
  }
});

ReactDOM.render(
	<GuineaPigs />,
	document.getElementById('app')
);

I’m in no big rush to get it solved though. Maybe if you post your code, we could help each other.


#3

Hi!
I am done with this course. You need to re write your GuineaPigs in the form of function, as per the instruction looking at Example.js file. Here is my code for reference.

var React = require('react');

function GuineaPigs (props){ 
 
    var src = props.src;
    return (
      <div>
        <h1>Cute Guinea Pigs</h1>
        <img src={src} />
      </div>
    );
  }
GuineaPigs.propTypes = {
src: React.PropTypes.string.isRequired  
}

module.exports = GuineaPigs;

#4

Got it, thanks. I must have overlooked something while trying to complete the section.


#5

Not a Problem :slight_smile:


#6

Thank you for your message. I found the answer how to make GuineaPigs.propTypes. I was stuck with that and thinking to ask help here.


#7

Hi I am stuck on this exercise with an error message (below) that is not helpful.
I tried copy pasting the code provided by @webblaster78944. Is anbody else getting this error?

Here’s the error message I get:

Warning: Failed propType: Required prop src was not specified in GuineaPigs.
{


#8

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