Ensures that any component or prop methods used to handle events are correctly prefixed.
Examples of incorrect code for this rule:
<MyComponent handleChange={this.handleChange} />
<MyComponent onChange={this.componentChanged} />
Examples of correct code for this rule:
<MyComponent onChange={this.handleChange} />
<MyComponent onChange={this.props.onFoo} />
...
"react/jsx-handler-names": [<enabled>, {
"eventHandlerPrefix": <eventHandlerPrefix>,
"eventHandlerPropPrefix": <eventHandlerPropPrefix>,
"checkLocalVariables": <boolean>,
"checkInlineFunction": <boolean>
}]
...
eventHandlerPrefix
: Prefix for component methods used as event handlers. Defaults tohandle
eventHandlerPropPrefix
: Prefix for props that are used as event handlers. Defaults toon
checkLocalVariables
: Determines whether event handlers stored as local variables are checked. Defaults tofalse
checkInlineFunction
: Determines whether event handlers set as inline functions are checked. Defaults tofalse
If you are not using JSX, or if you don't want to enforce specific naming conventions for event handlers.