Skip to content

Commit c7f97b0

Browse files
committed
react [nfc]: Use import * as React in reactUtils.js
1 parent 7d669d6 commit c7f97b0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/reactUtils.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* @flow strict-local */
22
import 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`.
2727
export 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) {
7171
export 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
136136
export 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

Comments
 (0)