我正在使用以下方法克隆一个组件并修改其属性。
const clone = React.cloneElement(<BallComponent>, {
key: new Date().getTime()
});
我如何在这个克隆组件上添加点击事件并在其类中调用函数? 我尝试了以下方法,但没有成功:
const clone = React.cloneElement(<BallComponent>, {
key: new Date().getTime()}
onClick: alert('test');
});