Hello everyone,
I am working on the copycat project in the react section. Here is a link to the project:
CopyCat
I completed the PropTypes section of the project, but I am not sure if it’s working properly or not. Here is my CopyCat.js as reference:
import React from 'react';
import {styles} from '../styles.js';
import PropTypes from 'prop-types';
const images = {
copycat: 'https://content.codecademy.com/courses/React/react_photo_copycat.png',
quietcat: 'https://content.codecademy.com/courses/React/react_photo_quietcat.png'
};
export default class CopyCat extends React.Component {
render() {
const copying = this.props.copying;
const toggleTape = this.props.toggleTape;
const input = this.props.input;
const handleChange = this.props.handleChange;
const name = this.props.name;
return (
<div style = {styles.divStyles}>
<h1 style = {{marginBottom:80}}>Copy Cat{name ? name:' Tom'}</h1>
<input type ='text'
value = {input}
onChange = {handleChange}/>
<img
style = {styles.imgStyles}
alt='cat'
src={copying ? images.copycat : images.quietcat}
onClick={toggleTape}
/>
<p>{copying ? input: ''}</p>
</div>
);
};
}
CopyCat.propTypes = {
copying:PropTypes.bool.isRequired,
toggleTape:PropTypes.func.isRequired,
input: PropTypes.string.isRequired,
handleChange: PropTypes.func.isRequired,
name: PropTypes.string.isRequired
}
My question is how do I know if the propTypes section is working? From what I recall, I receive some sort of warning message when one of the props doesn’t receive the designated data type ie ‘string’, ‘bool’,‘func’, etc. Would I receive this message in the console?
I opened the console and saw this warning:
Does that mean there is an error in one of my PropTypes? Any help is appreciated. Happy coding everyone