react-prevent-default
v1.0.0
Published
Takes a function and returns a function that calls preventDefault on the last argument of the function
Downloads
13,463
Maintainers
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
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.