Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

react-bound-fn

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-bound-fn

Gets bound React functions so you can stub/spy on them.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

React-Bound-Fn

A react.js helper function that returns an object with object and method properties so you can stub/spy with ease.

Installation

React-Bound-Fn requires React 0.14 or later.

npm install --save react-bound-fn

React-Bound-Fn uses CommonJS-style requires, which assumes you are using a module bundler like Browserify or Webpack.

Usage

import rbf from 'react-bound-fn';

// In your mocha unit test...
const boundFunction = rbf(Object, 'myFunction');
sinon.spy(boundFunction.object, boundFunction.method);

Why?

Finding how to stub or spy on React component methods has been very confusing. Originally it was by accessing __reactAutoBindMap, and then they changed it in v15.0 to __reactAutoBindPairs. To avoid any more headaches and make your life easier, just use React-Bound-Fn to get the object and method for you.

License

ISC

Keywords

react

FAQs

Package last updated on 11 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts