-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(use-image): cached image flickering issue (#4442)
* feat(use-image): add test case * feat(use-image): include `@nextui-org/react-utils` * feat(react-utils): add useIsHydrated * fix(use-image): cached image flickering issue * fix(use-image): ensure status is set after hydrated * chore(use-image): remove unneccessary code
- Loading branch information
Showing
8 changed files
with
98 additions
and
193 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 @@ | ||
--- | ||
"@nextui-org/react-utils": patch | ||
--- | ||
|
||
add useIsHydrated |
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 @@ | ||
--- | ||
"@nextui-org/use-image": patch | ||
--- | ||
|
||
fix cached image flickering issue (#4271) |
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
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,30 @@ | ||
import * as React from "react"; | ||
|
||
/** | ||
* A hook that returns true if the component is mounted on the client (hydrated) | ||
* and false when rendering on the server. | ||
* | ||
* @example | ||
* ```jsx | ||
* function Component() { | ||
* const isHydrated = useIsHydrated() | ||
* | ||
* if (!isHydrated) { | ||
* return <div>Loading...</div> | ||
* } | ||
* | ||
* return <div>Client rendered content</div> | ||
* } | ||
* ``` | ||
* @returns boolean indicating if the component is hydrated | ||
*/ | ||
|
||
export function useIsHydrated() { | ||
const subscribe = () => () => {}; | ||
|
||
return React.useSyncExternalStore( | ||
subscribe, | ||
() => true, | ||
() => false, | ||
); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.