我在 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 ×1