javascript - 如何列出 props 变量中的项目?

标签 javascript reactjs

列出和迭代 props 变量中的变量键和值的最简单方法是什么?

我无法使用 PureComponent,我应该检查 componentWillReceiveProps(nextProps)shouldComponentUpdate(nextProps, nextState) 函数中的变量。

谢谢!

最佳答案

您可以对其进行映射,例如

for (let key in nextProps) {
    const value = nextProps[key]
}

关于javascript - 如何列出 props 变量中的项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54462226/

相关文章:

javascript - 如何设置和获取加载圆圈@keyframe 的值

android - React Native 调试器无法导入 bundle 脚本?

javascript - Webpack5模块联合: “Uncaught Error: could not find react-redux context value; please ensure the component is wrapped in a <Provider>”

javascript - 创建 hello world Reactjs 应用程序

javascript - 处理错误后跳过 promise 链

javascript - 2038年之后的momentjs夏令时

javascript - 你能在同一个项目中让客户端和服务器端使用react吗?

express - 在 Isomorphic React 上处理 SEO

javascript - 脚本未导入用于在 Canvas 中工作的文件

javascript - 检查输入字符串是否为正 int/float 数