小编ken*_*n_o的帖子

React 功能组件中的第二个参数是什么?

我在 React.js 功能组件中注意到,如:

import React from 'react';
import ReactDOM from 'react-dom';

function MyComponent(props, whatIsThisFor) {
  console.log(JSON.stringify(whatIsThisFor)); // logs {} to console
  return <div></div>
}

ReactDOM.render(<MyComponent />, document.getElementById('root'));
Run Code Online (Sandbox Code Playgroud)

whatIsThisFor呈现时参数会设置为空对象。我在任何文档中都找不到此参数的用途。有谁知道它是做什么用的?

reactjs

9
推荐指数
1
解决办法
2403
查看次数

标签 统计

reactjs ×1