Skip to content

Commit 4eafc24

Browse files
gnpricechrisbobbe
authored andcommitted
reactUtils [nfc]: Add caveat to useHasStayedTrueForMs about value changing
Based on this discussion thread: #5489 (comment)
1 parent bf1f452 commit 4eafc24

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/reactUtils.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ export function useDebugAssertConstant<T>(value: T) {
6060
*
6161
* The caller must use a constant `duration` through the lifetime of a given
6262
* component instance.
63+
*
64+
* Note this hook doesn't (and can't) do anything to cause a rerender when
65+
* `value` changes. The caller must ensure that the component rerenders (so
66+
* that in particular this hook gets called again) whenever `value` will
67+
* have changed; for example, by using a prop or a `useState` value.
6368
*/
6469
export const useHasStayedTrueForMs = (value: boolean, duration: number): boolean => {
6570
useDebugAssertConstant(duration);

0 commit comments

Comments
 (0)