小编fri*_*ies的帖子

props 的展开运算符没有传递给组件

我在将展开运算符道具传递给组件时遇到问题。它不是返回一个包含值的列表,而是返回一个空列表。

这就是我将 props 传递给组件的方式

const APIKey = "abc";
const url = "def";
const props = { APIKey, url}
return (
      <ProfileModal {...props} />
)
Run Code Online (Sandbox Code Playgroud)

但是,它返回一个空列表。

const FunctionName = (anotherPropIhave, props) => {
      const { APIKey, url } = props;
}
Run Code Online (Sandbox Code Playgroud)

reactjs react-props

0
推荐指数
1
解决办法
264
查看次数

标签 统计

react-props ×1

reactjs ×1