Skip to content

Commit 86ea850

Browse files
committed
reactUtils [nfc]: Add caveat to useHas…ForMs about value changing
Based on this discussion thread: #5489 (comment)
1 parent f025775 commit 86ea850

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/reactUtils.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ export function useDebugAssertConstant<T>(value: T) {
6262
*
6363
* The caller must use a constant `duration` through the lifetime of a given
6464
* component instance.
65+
*
66+
* Note this hook doesn't (and can't) do anything to cause a rerender when
67+
* `value` changes. The caller must ensure that the component rerenders (so
68+
* that in particular this hook gets called again) whenever `value` will
69+
* have changed; for example, by using a prop or a `useState` value.
6570
*/
6671
export function useHasNotChangedForMs(value: mixed, duration: number): boolean {
6772
useDebugAssertConstant(duration);
@@ -97,6 +102,11 @@ export function useHasNotChangedForMs(value: mixed, duration: number): boolean {
97102
*
98103
* The caller must use a constant `duration` through the lifetime of a given
99104
* component instance.
105+
*
106+
* Note this hook doesn't (and can't) do anything to cause a rerender when
107+
* `value` changes. The caller must ensure that the component rerenders (so
108+
* that in particular this hook gets called again) whenever `value` will
109+
* have changed; for example, by using a prop or a `useState` value.
100110
*/
101111
export const useHasStayedTrueForMs = (value: boolean, duration: number): boolean => {
102112
useDebugAssertConstant(duration);

0 commit comments

Comments
 (0)