11/* @flow strict-local */
22import invariant from 'invariant' ;
3- import { useRef , useEffect , useState } from 'react' ;
3+ import * as React from 'react' ;
44
55/**
66 * A Hook for the value of a prop, state, etc., from the previous render.
@@ -25,8 +25,8 @@ import { useRef, useEffect, useState } from 'react';
2525// (because effectively the `?` would handle it instead), and so `U` would
2626// be the empty type and `T | U` would be just `T`.
2727export function usePrevious < T , U > ( value : T , initValue : U ) : T | U {
28- const ref = useRef < T | U > ( initValue ) ;
29- useEffect ( ( ) => {
28+ const ref = React . useRef < T | U > ( initValue ) ;
29+ React . useEffect ( ( ) => {
3030 ref . current = value ;
3131 } ) ;
3232 return ref . current ;
@@ -48,7 +48,7 @@ export function useDebugAssertConstant<T>(value: T) {
4848
4949 // Conditional, but on a per-process constant.
5050 // eslint-disable-next-line react-hooks/rules-of-hooks
51- const origValue = useRef ( value ) ;
51+ const origValue = React . useRef ( value ) ;
5252 invariant ( value === origValue . current , '' ) ;
5353}
5454
@@ -71,9 +71,9 @@ export function useDebugAssertConstant<T>(value: T) {
7171export function useHasNotChangedForMs ( value : mixed , duration : number ) : boolean {
7272 useDebugAssertConstant ( duration ) ;
7373
74- const [ result , setResult ] = useState ( false ) ;
74+ const [ result , setResult ] = React . useState ( false ) ;
7575
76- useEffect ( ( ) => {
76+ React . useEffect ( ( ) => {
7777 setResult ( false ) ;
7878 const id = setTimeout ( ( ) => setResult ( true ) , duration ) ;
7979 return ( ) => clearTimeout ( id ) ;
@@ -134,4 +134,4 @@ export const useHasStayedTrueForMs = (value: boolean, duration: number): boolean
134134// docs could be clearer about that:
135135// https://reactjs.org/docs/hooks-effect.html#tip-optimizing-performance-by-skipping-effects
136136export const useConditionalEffect = ( cb : ( ) = > void | ( ( ) => void ) , value : boolean ) : void =>
137- useEffect ( ( ) => ( value ? cb ( ) : undefined ) , [ value , cb ] ) ;
137+ React . useEffect ( ( ) => ( value ? cb ( ) : undefined ) , [ value , cb ] ) ;
0 commit comments