Socket
Socket
Sign inDemoInstall

react-toggle-aware

Package Overview
Dependencies
2
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-toggle-aware

A tiny higher order component to track toggle state.


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Created
Weekly downloads
 

Readme

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

Last updated on 25 Feb 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc