-
-
Notifications
You must be signed in to change notification settings - Fork 421
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🗑️ Deprecated
useEffectOnce
, useIsFirstRender
and `useUpdateEffec…
…t` (#477)
- Loading branch information
Showing
9 changed files
with
17 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"usehooks-ts": patch | ||
--- | ||
|
||
Deprecated `useEffectOnce`, `useIsFirstRender` and `useUpdateEffect` |
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 |
---|---|---|
@@ -1,7 +1 @@ | ||
Just modified version of `useEffect` that's executed only one time, at the mounting time. | ||
|
||
See also: | ||
|
||
- [`useUpdateEffect()`](/react-hook/use-update-effect): Inverse of `useEffectOnce()` | ||
- [`useIsFirstRender()`](/react-hook/use-is-first-render): Return a `boolean` | ||
- [`useIsMounted()`](/react-hook/use-is-mounted): Callback function to avoid Promise execution after component un-mount | ||
This hook is **deprecated** and will be dropped in the next major release because it can be misleading. It doesn't actually perform its action only once, but rather during mounting. Given its limited logic, it's better to use React's API directly without adding unnecessary abstraction. |
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
11 changes: 1 addition & 10 deletions
11
packages/usehooks-ts/src/useIsFirstRender/useIsFirstRender.md
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 |
---|---|---|
@@ -1,10 +1 @@ | ||
Simple React hook that return a boolean; | ||
|
||
- True at the mount time | ||
- Then always false | ||
|
||
See also: | ||
|
||
- [`useEffectOnce()`](/react-hook/use-effect-once): A modified `useEffect()` executed only on mount | ||
- [`useUpdateEffect()`](/react-hook/use-update-effect): A modified `useEffect()` executed only on updates (skip first render) | ||
- [`useIsMounted()`](/react-hook/use-is-mounted): Callback function to avoid Promise execution after component un-mount | ||
This hook is **deprecated** and will be dropped in a future major release. `useEffect` is designed for synchronization. React 18 emphasizes this concept by rendering components twice in strict mode to highlight improper usage. Attempting to skip the first render is considered a hack. |
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 |
---|---|---|
@@ -1,7 +1 @@ | ||
Just modified version of `useEffect` that is skipping the first render. | ||
|
||
See also: | ||
|
||
- [`useEffectOnce()`](/react-hook/use-effect-once): Inverse of `useUpdateEffect()` | ||
- [`useIsFirstRender()`](/react-hook/use-is-first-render): Return a `boolean` | ||
- [`useIsMounted()`](/react-hook/use-is-mounted): Callback function to avoid Promise execution after component un-mount | ||
This hook is **deprecated** and will be dropped in a future major release. `useEffect` is designed for synchronization. React 18 emphasizes this concept by rendering components twice in strict mode to highlight improper usage. Attempting to skip the first render is considered a hack. |
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