-
-
Notifications
You must be signed in to change notification settings - Fork 2k
types: Require initial value in useRef
#4683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,13 +52,6 @@ export function useReducer<S, A, I>( | |
| init: (arg: I) => S | ||
| ): [S, Dispatch<A>]; | ||
|
|
||
| /** @deprecated Use the `Ref` type instead. */ | ||
| type PropRef<T> = MutableRef<T>; | ||
|
|
||
| interface MutableRef<T> { | ||
| current: T; | ||
| } | ||
|
|
||
| /** | ||
| * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument | ||
| * (`initialValue`). The returned object will persist for the full lifetime of the component. | ||
|
|
@@ -68,9 +61,9 @@ interface MutableRef<T> { | |
| * | ||
| * @param initialValue the initial value to store in the ref object | ||
| */ | ||
| export function useRef<T>(initialValue: T): MutableRef<T>; | ||
| export function useRef<T>(initialValue: T | null): RefObject<T>; | ||
| export function useRef<T = undefined>(): MutableRef<T | undefined>; | ||
| export function useRef<T>(initialValue: T): RefObject<T>; | ||
| export function useRef<T>(initialValue: T | null): RefObject<T | null>; | ||
| export function useRef<T>(initialValue: T | undefined): RefObject<T | undefined>; | ||
|
Comment on lines
+64
to
+66
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| type EffectCallback = () => void | (() => void); | ||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,9 +37,9 @@ export interface VNode<P = {}> { | |
|
|
||
| export type Key = string | number | any; | ||
|
|
||
| export type RefObject<T> = { current: T | null }; | ||
| export type RefObject<T> = { current: T }; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. React for reference. Setting |
||
| export type RefCallback<T> = (instance: T | null) => void; | ||
| export type Ref<T> = RefObject<T> | RefCallback<T> | null; | ||
| export type Ref<T> = RefCallback<T> | RefObject<T | null> | null; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| export type ComponentChild = | ||
| | VNode<any> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has never existed in React's types, not quite sure what it was supposed to be either.