An open API service indexing awesome lists of open source software.

https://github.com/tusbar/react-event-utils

Shorthand utils for dealing with React events
https://github.com/tusbar/react-event-utils

events persist preventdefault react stoppropagation

Last synced: about 2 months ago
JSON representation

Shorthand utils for dealing with React events

Awesome Lists containing this project

README

          

# react-event-utils

[![Build Status](https://travis-ci.org/tusbar/react-event-utils.svg?branch=master)](https://travis-ci.org/tusbar/react-event-utils)

> Shorthand utils for dealing with React events

# Install

```cli
$ yarn add react-event-utils
```

# About

This library exposes shorthand methods that call event methods for you.

This will allow you to stop having components like this:

```jsx
class Form extends React.Component {
constructor(props) {
super(props);

this.handleSubmit = this.handleSubmit.bind(this);
}

handleSubmit(e) {
e.preventDefault();

doSomething(e.target.title.value);
}

render() {
return (



);
}
}
```

While you could just write:

```jsx
import { preventDefault /*, persist, stopPropagation */ } from 'react-event-utils';

export const Form = () =>
doSomething(e.target.title.value))}>

;
```

Currently `persist`, `preventDefault` and `stopPropagation` are implemented.

# License

MIT © [Bertrand Marron](https://github.com/tusbar)