now you need to make an embedded component SA, to capture user click behavior. About as follows
<SA name="6666">
<h1></h1>
</SA>
when the user clicks H1, the console enters 666
requires that SA cannot return additional html, but can only return children,. That is to say, SA itself does not have a click event, but hijacks the click event of the number of children
//
function SA({children,name}){
return children.map(child=>{
let onNewClick=(e)=>{
let onClick=child.onClick
console.log(name)
onClick&&onClick(e)
}
child.props.onClick=onNewClick
return child
})
}
< H2 > the above pseudo code is not good at all, just so that the viewer can understand it. Previously solved through React.cloneElement, at least the function can be performed, but caused other problems. Online and other solutions < / H2 >