I have a component that might or might not recieve an onClick
prop. I want to attatch this non-required prop as a click handler.
const MyComponent = (props) => {
let {onClick} = props;
return (
<div onClick={onClick}></div>
);
}
Whats the safest way to do this sort of thing if I don't know if the handler will be given?