Jake He
Jake He

Reputation: 2815

Click child component by clicking the parent component

Is it possible to pass the click event from the parent to the child? So when Button is clicked FileUpload is clicked too. My working code is here.

https://codesandbox.io/s/uploadbutton-78h2d

<Button>
 <Dialog>
      <FileUpload/>
 </Dialog>
</Button>

Upvotes: 1

Views: 53

Answers (1)

technicallynick
technicallynick

Reputation: 1592

Simply have the onClick event listener on the Button instead of the FileUpload (or have it on both but make sure you're stopping propagation so it doesn't double-fire the event.

Upvotes: 1

Related Questions