https://github.com/donavon/prevent-default
A wrapper that calls `event.preventDefault()` for you.
https://github.com/donavon/prevent-default
Last synced: 8 months ago
JSON representation
A wrapper that calls `event.preventDefault()` for you.
- Host: GitHub
- URL: https://github.com/donavon/prevent-default
- Owner: donavon
- License: mit
- Created: 2016-06-23T13:45:53.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-06-23T16:36:27.000Z (over 9 years ago)
- Last Synced: 2025-02-07T18:08:53.538Z (8 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @donavon/prevent-default
[](https://travis-ci.org/donavon/prevent-default)A wrapper that calls event.preventDefault() for you.
## Install
```
> npm i @donavon/prevent-default --save
```## Usage
To use `prevent-default`, simply `import` it (ES6) and wrap your `onClick` with `pd()` as shown below.
Although useful with React components, it is not React specific and can be used without React.```js
import pd from "@donavon/prevent-default";const noClicking = () => {
alert("You can't click here, buddy!");
}const MyLinkComponent = ({ children }) => {
return (
{children}
);
};export default MyLinkComponent;
```
Don't recognize the format of the React component shown above? It's stateless. You should be using [stateless components](https://facebook.github.io/react/docs/reusable-components.html#stateless-functions) in your app when applicable.