Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@clayui/core): fixes error when deselecting the indeterminate sta…
…te for pre selected items in the first render This behavior should only happen when items change, as in React.js, regardless of the first render it will invoke useEffect, in this scenario this ends up breaking the hydrate behavior of the first render for the selected items. So we prevent this case from being computed on the first rendering and only being called when the items change.
- Loading branch information
1 parent
ad2dff6
commit 997461e
Showing
3 changed files
with
30 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* SPDX-FileCopyrightText: © 2023 Liferay, Inc. <https://liferay.com> | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
import {useRef} from 'react'; | ||
|
||
export function useIsFirstRender(): boolean { | ||
const isFirst = useRef(true); | ||
|
||
if (isFirst.current) { | ||
isFirst.current = false; | ||
|
||
return true; | ||
} | ||
|
||
return isFirst.current; | ||
} |
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