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

@shopify/react-hooks

Package Overview
Dependencies
Maintainers
13
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/react-hooks - npm Package Compare versions

Comparing version 1.3.2 to 1.4.0

dist/src/hooks/toggle.d.ts

4

CHANGELOG.md

@@ -10,2 +10,6 @@ # Changelog

## [1.4.0] - 2019-12-19
- Added `useToggle` hook ([#1220](https://github.com/Shopify/quilt/pull/1220))
## [1.3.0] - 2019-10-29

@@ -12,0 +16,0 @@

7

dist/src/hooks/index.d.ts
export { useLazyRef } from './lazy-ref';
export { default as useTimeout } from './timeout';
export { default as useOnValueChange } from './on-value-change';
export { useMountedRef } from './mounted-ref';
export { default as usePrevious } from './previous';
export { useOnValueChange } from './on-value-change';
export { usePrevious } from './previous';
export { useTimeout } from './timeout';
export { useToggle } from './toggle';
//# sourceMappingURL=index.d.ts.map

@@ -5,9 +5,11 @@ "use strict";

exports.useLazyRef = lazy_ref_1.useLazyRef;
var timeout_1 = require("./timeout");
exports.useTimeout = timeout_1.default;
var on_value_change_1 = require("./on-value-change");
exports.useOnValueChange = on_value_change_1.default;
var mounted_ref_1 = require("./mounted-ref");
exports.useMountedRef = mounted_ref_1.useMountedRef;
var on_value_change_1 = require("./on-value-change");
exports.useOnValueChange = on_value_change_1.useOnValueChange;
var previous_1 = require("./previous");
exports.usePrevious = previous_1.default;
exports.usePrevious = previous_1.usePrevious;
var timeout_1 = require("./timeout");
exports.useTimeout = timeout_1.useTimeout;
var toggle_1 = require("./toggle");
exports.useToggle = toggle_1.useToggle;

@@ -1,2 +0,2 @@

export default function useOnValueChange<T>(value: T, onChange: (value: T, oldValue: T) => void): void;
export declare function useOnValueChange<T>(value: T, onChange: (value: T, oldValue: T) => void): void;
//# sourceMappingURL=on-value-change.d.ts.map

@@ -13,2 +13,2 @@ "use strict";

}
exports.default = useOnValueChange;
exports.useOnValueChange = useOnValueChange;

@@ -1,2 +0,2 @@

export default function usePrevious<T>(value: T): T | undefined;
export declare function usePrevious<T>(value: T): T | undefined;
//# sourceMappingURL=previous.d.ts.map

@@ -11,2 +11,2 @@ "use strict";

}
exports.default = usePrevious;
exports.usePrevious = usePrevious;

@@ -1,2 +0,2 @@

export default function useTimeout(callback: () => void, delay: number): void;
export declare function useTimeout(callback: () => void, delay: number): void;
//# sourceMappingURL=timeout.d.ts.map

@@ -11,2 +11,2 @@ "use strict";

}
exports.default = useTimeout;
exports.useTimeout = useTimeout;
{
"name": "@shopify/react-hooks",
"version": "1.3.2",
"version": "1.4.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "A collection of primitive React hooks.",

@@ -105,1 +105,26 @@ # `@shopify/react-hooks`

```
### `useToggle()`
This hook will provide an object that contains a boolean state value and a set of memoised callbacks to toggle it, force it to true and force it to false. It accepts one argument that is the initial value of the state. This is useful for toggling the active state of modals and popovers.
```tsx
function MyComponent() {
const {
value: isActive,
toggle: toggleIsActive,
setTrue: setIsActiveTrue,
setFalse: setIsActiveFalse,
} = useToggle(false);
const activeText = isActive ? 'true' : 'false';
return (
<>
<p>Value: {activeText}</p>
<button onClick={toggleIsActive}>Toggle isActive state</button>
<button onClick={setIsActiveTrue}>Set isActive state to true</button>
<button onClick={setIsActiveFalse}>Set isActive state to false</button>
</>
);
}
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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