Tell us what’s happening:
I’d like to know what he Fruits and Vegetables components behind the scenes look like, because I tried to make it in scrimba.com and codepen.io and can’t figure it out.
Here’s what I tried: const TypesOfFood = [ [Fruits = "Oranges, Apples"], [Vegetables: "Potatoes, Cabagge"] ],
but nothing works
Your code so far
class TypesOfFood extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div>
<h1>Types of Food:</h1>
{/* change code below this line */}
{/* change code above this line */}
</div>
);
}
};
// change code below this line
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36.
You have the Fruits and Vegetables as both class and function components. You also can not export two defaults like you are. Give each component its own file and export/import them as needed.
You can export more than one component but it is usually better to have one file for each component.
./src/TypesOfFood.js Line 66: Expected an assignment or function call and instead saw an expression no-unused-expressionsSearch for the keywords to learn more about each error.
Post a link to your current code on StackBlitz like you did before.
Without seeing your current code I would imagine that only Vegetables are being exported. As I understand it, when using parentheses in the export the operands get interpreted as expressions.
To see what I mean you can put this into the browser console.
What exactly is it you believe adding {One} and {Two} is supposed to do? You don’t have any variables, props or state that they can be referring so what is the value of One and Two inside the h2?
BTW, I still don’t see your updated code. The code in the stackblitz you have linked to is still wrong.
Edit: you also have this fork of the code I posted, is that the one you are now using?
I mean don’t use them at all. You don’t need the components to exist at all if you are not going to use them.
If you just want to keep them for reference just don’t import them or use them in the TypesOfFood component. You can comment out the import and the component inside TypesOfFood if you want to keep all the code but not use it.