如何将值输入到我的对象中,以将其作为React中的props传递

huangapple go评论80阅读模式
英文:

How could I Type value inside my object to pass it as a props with react

问题

I discovered TypeScript and I would like to use it in my React App, because it's still possible but soon not.

So I was working on it, and for an hour, I'm stuck. I would like to know what's exactly wrong with it and what should I do?

To me, it's a type error. That's why I got 'Property 'name' does not exist on type 'never[]'.' But like I said, I'm a novice.

Is there someone to help me fix it and, most importantly, explain it to me a little bit?

Image of my code and the errors thrown

英文:

I discovered TypeScript and I would like to use it into my react App, cause it's still possible but soon not.

So I was working on and from an hour I'm stuck on it... I would like to know what exactly wrong with it and what should I do?

To me it's a type error that's why I got 'Property 'name' does not exist on type 'never[]'.' but like said I'm a novice.

Someone there to help me to fix it and most important explain to me a little bit?

Image of my code and the errors throws

答案1

得分: 0

你应该将你的常量数据指定为任何类型,像这样:const data: any{} = ...

英文:

You should specify your const data as any type, like this: const data: any{} = ...

huangapple
  • 本文由 发表于 2020年1月4日 00:17:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/59581836.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定