react Material-ui, How do I know I can use onClick for button?

eugene picture eugene · Oct 21, 2016 · Viewed 93.1k times · Source

The list of properties on the doc doesn't include onClick (http://www.material-ui.com/#/components/icon-button)

How do I know I need to use onClick for click handler?

Answer

thirtydot picture thirtydot · Oct 21, 2016

The Material-UI documentation does not list the standard React (native browser) events:

https://facebook.github.io/react/docs/events.html#mouse-events

This is because it's expected that you are already aware of the available native events. For example, you can also use onWheel. It would be a long and redundant list if all the native events were included.

As kouak explains, other props (such as onClick) are passed down to a relevant child component.

Random example:

<Button color="primary" onClick={() => { console.log('onClick'); }}>
    Primary
</Button>