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

@hashicorp/react-boolean-input

Package Overview
Dependencies
Maintainers
17
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hashicorp/react-boolean-input - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

14

index.js

@@ -21,7 +21,12 @@ import React, { useState, useEffect } from 'react'

// set up state for the input value
const [stateValue, setValue] = useState(value || false)
const [stateValue, setValue] = useState(false)
const [isDirty, setIsDirty] = useState(false)
// if the parent changes the value, reflect it to state
useEffect(() => setValue(value), [value])
// if the state changes the value, reflect it to the parent
useEffect(() => onValueChange && onValueChange(stateValue), [stateValue])
useEffect(() => {
// if the input hasn't been touched, don't pass up the value
if (!isDirty) return
return onValueChange && onValueChange(stateValue)
}, [stateValue])
// generate a uid to pair the label to the input

@@ -44,3 +49,6 @@ const uid = useUID()

value={stateValue}
onChange={e => setValue(e.target.checked)}
onChange={e => {
setIsDirty(true)
return setValue(e.target.checked)
}}
/>

@@ -47,0 +55,0 @@ <label htmlFor={`id-${name}-${uid}`}>

{
"name": "@hashicorp/react-boolean-input",
"description": "A checkbox input",
"version": "1.0.1",
"version": "1.0.2",
"main": "dist",

@@ -18,3 +18,3 @@ "dependencies": {

},
"gitHead": "5e68e058130d4c2fa54017babdae06568acff6be"
"gitHead": "2f16ae732cb52aebad1e0e533952c6b526ac7701"
}

Sorry, the diff of this file is not supported yet

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