Used a mapping function to display information from an array into 3 tiers, from what I can see everything seems right but none of the information is being displayed, can someone look at the code and tell me if there is something that I am missing
import React from 'react'
import styled from 'styled-components'
function Plans() {
const notePlans = [
{
name:"NoteZ Free",
price:"$0",
features: [
"1 user per account",
"Unlimited notes",
"4 categories to choose from",
"Help Support"
]
},
{
name:"NoteZ +",
price:"$5",
features: [
"2-4 users per account",
"Unlimited notes",
"Folder system for notes",
"Custom categories",
"Custom templates to choose from",
"Help Support"
]
},
{
name:"NoteZ Infinity",
price:"$10",
features: [
"Unlimited users per account",
"Unlimited notes",
"Folder system for notes",
"Custom categories",
"Full integration with MealZ",
"Full integration with WorkoutZ",
"Custom templates to choose from",
"Help Support"
]
}
]
return (
<Main>
<div className='pricing-container'>
{notePlans.map((plan) => (
<div className='pricing-card' key={plan.name}>
<h2>{plan.name}</h2>
<p>{plan.price}</p>
<ul>
{plan.features.map((feature,index) => (
<li key={index}>{feature}</li>
))}
</ul>
<button>Buy Now</button>
</div>
))}
</div>
</Main>
)
}
const Main = styled.div`
width:100%;
.pricing-container{
border:1px solid black;
color black;
}
`;
export default Plans
I tried adding the key when the console reported an error saying that a key was needed.
2
Answers
Try this:
There was a missing ":", after
color
.Also it works here: https://codesandbox.io/s/agitated-jepsen-5zdl2y?file=/src/App.js
Try adding return statement in your map callback function like this :