0

How do I render a JSON data dynamically into a component using something like an array.map method with Typescript. for example. I get an error from the code below.

const PricingSection: FC<IProps> = ({ icon, title, price, user, observations,
projects, interviews, buttonType }) => 

const mapped = map(datas => (

        <ul style={{ display: 'flex' }}>
            {datas.icon}
        </ul>
    )
Kenny
  • 1
  • 1
  • 3

1 Answers1

0

You're seemingly not far off... Assuming it's the 'observations' prop that is the array you're wanting to traverse:

const mapped = observations.map(datas => (

        <ul style={{ display: 'flex' }}>
            {datas.icon}
        </ul>
    )

In response to the comment chain where you call out (parameter) datas: any Parameter 'datas' implicitly has an 'any' type.ts(7006) , that is more of a linter typing callout than an error... It is saying that you are implicitly having the type

(datas: any => 

You can resolve it by explicitly putting a type on the datas object like this:

(datas: DataObject =>
MicScoPau
  • 66
  • 6