# react-prevent-default

> Takes a function and returns a function that calls preventDefault on the last argument of the function

Latest version **1.0.0** (published 2016-03-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-prevent-default
pnpm add react-prevent-default
yarn add react-prevent-default
bun add react-prevent-default
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-03-24 |
| First published | 2016-03-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | BJ Terry |
| Maintainers | bjterry |
| Keywords | react, prevent-default, preventDefault |

## Links

- npm: https://www.npmjs.com/package/react-prevent-default
- Repository: https://github.com/BJTerry/react-prevent-default
- Homepage: https://github.com/BJTerry/react-prevent-default#readme
- Issues: https://github.com/BJTerry/react-prevent-default/issues
- npm.io page: https://npm.io/package/react-prevent-default

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2016-03-24

## README

### Pay Attention, This is Important

This package solves a longstanding issue in React, Flux, Redux and many other applications: preventDefault getting scattered all over your code. Simply pass your event handler through this function and it will automatically have its default prevented. JavaScript magic!

# Example

```js
var preventDefault = require('react-prevent-default');
var LinkClicker = React.createClass({
    render: function(){
        return <a href="#" onClick={preventDefault(doSomethingCool.bind(null, 1, 2, 3))}> Click me for something cool to happen with 1 2 and 3 </a>;
    },
});
```

With the above code, you won't see an unsightly hash appear in your page url. 

## WARNING: MAY ALSO WORK WITH NON-REACT CODE.

---
_Source: https://npm.io/package/react-prevent-default · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
