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
- Host: GitHub
- URL: https://github.com/tusbar/react-event-utils
- Owner: tusbar
- License: mit
- Created: 2017-04-24T22:25:06.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-25T00:21:54.000Z (about 9 years ago)
- Last Synced: 2025-09-19T05:24:28.037Z (9 months ago)
- Topics: events, persist, preventdefault, react, stoppropagation
- Language: JavaScript
- Size: 37.1 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# react-event-utils
[](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)