markdown 38 - 传递未知的道具

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 38 - 传递未知的道具相关的知识,希望对你有一定的参考价值。

- missing props, reason for this is that in our HOC withClass component, we're outputting wrappedComponent
- wrappedComponent can be either App.js or Person.js
- these components get props but they don't anymore because we don't pass them in wrappedComponent
- we can't hard code these props obviously
- there is a simple thing we can do, pass on the existing props
- do this by taking advantage of the spread operator: props is just an object of key/value pairs
- `<WrappedComponent {...props} />`
- the above simply means pass on the props as you get them, split them up into key/value pairs

以上是关于markdown 38 - 传递未知的道具的主要内容,如果未能解决你的问题,请参考以下文章