问题描述
是否有一个编译器选项可以允许以下代码进行编译,而无需将函数定义移至底部?
import { message,Button } from 'antd';
const info = () => {
// How to make component / api like this?
message.info('This is a normal message');
};
ReactDOM.render(
<Button type="primary" onClick={info}>
Display normal message
</Button>,mountNode,);
解决方法
不,不是按值传递时。如果通过指针或引用传递了它,则可以。