New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-toggle-aware

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-toggle-aware

A tiny higher order component to track toggle state.

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

react-toggle-aware Build Status

A tiny higher order component to track toggle state.

Example

import { Component } from 'react';
import { toggleAware } from 'react-toggle-aware';

@toggleAware({ // same as default options
    onDelay: 0,
    offDelay: 0,
    handler: 'onToggle',
    key: 'isToggled'
})
class CustomComponent extends Component {

    render() {
        // props will include the toggle handler
        let { isToggled, className, ...props } = this.props;

        if (isToggled) className += ' on';

        return (
            <div {...props} className={className}>

            </div>
        )
    }
};

API

As a decorator
@toggleAware(options)
export default class Test extends React.Component {
    /* your code */
}
As a function
class Test extends React.Component {
    /* your code */
}

export default toggleAware(options)(Test);
Options
onDelay defaults to 0

Time in ms to wait before setting the active status to true.

offDelay defaults to 0

Time in ms to wait before setting the active status to false.

handler defaults to 'onToggle'

Property name to expose the handler as.

key defaults to 'isToggled'

Property name to expose the active status as.

Keywords

FAQs

Package last updated on 25 Feb 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

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