-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Popup): add transition complete events
transition
- Loading branch information
Showing
6 changed files
with
58 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# usePrevious | ||
|
||
The `usePrevious` hook stores the previous value during renders | ||
|
||
## Properties | ||
|
||
| Name | Description | Type | Default | | ||
| :---- | :------------------------------- | :---: | :-----: | | ||
| value | Any value, usually from useState | `any` | | | ||
|
||
## Result | ||
|
||
Previous value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {usePrevious} from './usePrevious'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
|
||
export function usePrevious<T>(value: T): T | undefined { | ||
const currentRef = React.useRef<T>(value); | ||
const previousRef = React.useRef<T>(); | ||
if (currentRef.current !== value) { | ||
previousRef.current = currentRef.current; | ||
currentRef.current = value; | ||
} | ||
return previousRef.current; | ||
} |