Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

simple-react-toggler

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

simple-react-toggler

`react-scroll-activator` watches for a scroll event inside of a container or on the window. When certain user-defined rules are met, it passes an `activatedState` prop to a render prop component, triggering whatever behavior the developer chooses on the c

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

react-toggler

react-toggler is a reusable toggle component. You can use it instead of building a custom toggle.

Table of Contents

  • Installation
  • Usage
  • Examples

Installation

npm install acq-components --save

Usage

The Toggle component follows the render prop pattern.

Toggle exposes three features to the user:

toggled is a boolean value that determines whether the Toggle is true or false.

toggleContent is a function that toggles between true and false.

To pass children to the component, that can access toggled and toggleContent, you can add a toggleProp to the <Toggle> like this:

<Toggle toggleProp={() => {}}>

Inside of that toggleProp, you can pass the children and the arguments that Toggle exposes, which are toggled and toggleContent:

<Toggle toggleProp={( // arguments go in here ) => {
  // children go in here
}}>
<Toggle toggleProp={({toggled, toggleContent}) => {
  return (
    <div>
      <button onClick={toggleContent} />
      <div toggled={toggled}>
    <div>
  )
}}>

Examples

Here's a real world example:

import { Toggle } from 'acq-components';

class App extends React.Component {
  render() {
    <Toggle
      toggled={false}
      toggleProp={({ toggled, toggleContent }) => (
        <div>
          {toggled ? <h1>On</h1> : <h2>Off</h2>}
          <button onClick={toggleContent}>Click Me</button>
        </div>
      )}
    />
  }
}

Contributors

Keywords

React

FAQs

Package last updated on 10 Jun 2018

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