I have searched everywhere for two days. For some reason, my FCC console is stating “require is not defined,” and nothing is rendering. What is wrong with my code???
import React, { PropTypes } from 'react';
const Items = (props) => {
return (<h1>Current Quantity of Items in Cart: {props.quantity}</h1>)
};
// change code below this line
Items.propTypes = {
quantity: PropTypes.number.isRequired
};
// change code above this line
Items.defaultProps = {
quantity: 0
};
class ShoppingCart extends React.Component {
constructor(props) {
super(props);
}
render() {
return <Items quantity={3}/>
}
};
What’s the FCC console, is that in the beta version? If it’s 16 or higher it needs to be imported specifically. This could be a sitewide issue then if others are having problems with it. Try another way, maybe codepen…where you have control over what libraries you’re including?
You would need to include react libraries as scripts like this, and can do that from codepen. But if your’e in the FCC console in beta, i’m guessing that’s on the backend. I don’t even know if that’s the issue, but if you have some patience, it’s worth trying this in a different editor, or even locally.
Note I coped these from a tutorial…the current React version is 16.3.2