1.0.4 • Published 7 years ago

cancel-handled v1.0.4

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
7 years ago

Allow ReactJS events to be canceled by returning true.

Installation

npm install --save cancel-handled

Usage

import React, { Component } from 'react'
import cancelHandled from 'cancel-handled'

class SomeComponent extends Component {
  handler(e) {
    console.log('Handler executed.')
    return true
  }

  render() {
    // The link won’t navigate because the handler returned true to indicate that
    // it handled the event already.
    return (
      <a
        href="/link"
        onClick={cancelHandled(this.handler)}
      >
        Ctrine!
      </a>
    )
  }
}
1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.0

7 years ago