Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-trigger-change

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-trigger-change

Trigger React's synthetic change events on input, textarea and select elements

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-trigger-change

Library for triggering React's synthetic change events on input, textarea and select elements.

In production builds of React ReactTestUtils.Simulate doesn't work because of dead code elimination. There is no other built-in way to dispatch synthetic change events.

This module is a hack and is tightly coupled with React's implementation details. Not intended for production use. Useful for end-to-end testing and debugging.

Install

With npm:

npm install react-trigger-change --save-dev

From a CDN:

<script src="https://unpkg.com/react-trigger-change/dist/react-trigger-change.js"></script>

Use

reactTriggerChange(DOMElement);

DOMElement - native DOM element, will be the target of change event.

One way to obtain a DOM element in React is to use ref attribute:

let node;
ReactDOM.render(
  <input
    onChange={() => console.log('changed')}
    ref={(input) => { node = input; }}
  />,
  mountNode
);

reactTriggerChange(node); // 'changed' is logged

Test

Build the browser bundle:

npm install
npm run build

Open test/test.html in the browser. Specify React version with a query string, for example:

?version=15.4.2 for React v15.4.2
?version=16.0.0-alpha.6&min=1 for minified React v16.0.0-alpha.6

Keywords

FAQs

Package last updated on 09 Apr 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc