@shopify/react-hooks
Advanced tools
Comparing version 1.2.5 to 1.3.0
@@ -10,2 +10,4 @@ # Changelog | ||
- Added a `usePrevious` hook ([#1145](https://github.com/Shopify/quilt/pull/1145)) | ||
## [1.2.0] - 2019-04-25 | ||
@@ -12,0 +14,0 @@ |
@@ -5,1 +5,2 @@ export { useLazyRef } from './lazy-ref'; | ||
export { useMountedRef } from './mounted-ref'; | ||
export { default as usePrevious } from './previous'; |
@@ -11,1 +11,3 @@ "use strict"; | ||
exports.useMountedRef = mounted_ref_1.useMountedRef; | ||
var previous_1 = require("./previous"); | ||
exports.usePrevious = previous_1.default; |
{ | ||
"name": "@shopify/react-hooks", | ||
"version": "1.2.5", | ||
"version": "1.3.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "A collection of primitive React hooks.", |
@@ -87,1 +87,19 @@ # `@shopify/react-hooks` | ||
``` | ||
### `usePrevious()` | ||
This hook will store the previous value of a given variable. | ||
```tsx | ||
function Score({value}) { | ||
const previousValue = usePrevious(value); | ||
const newRecord = value > previousValue ? <p>We have a new record!</p> : null; | ||
return ( | ||
<> | ||
<p>Current score: {value}</p> | ||
{newRecord} | ||
</> | ||
); | ||
} | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7971
17
89
105