Skip to content
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

compat: Improve React compatibility for Ref type. #4403

Merged
merged 2 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compat/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ declare namespace React {
export import PropRef = _hooks.PropRef;
export import Reducer = _hooks.Reducer;
export import Dispatch = _hooks.Dispatch;
export import Ref = _hooks.Ref;
rschristian marked this conversation as resolved.
Show resolved Hide resolved
export import SetStateAction = _hooks.StateUpdater;
export import useCallback = _hooks.useCallback;
export import useContext = _hooks.useContext;
Expand Down Expand Up @@ -50,6 +49,7 @@ declare namespace React {
export import ComponentClass = preact.ComponentClass;
export import FC = preact.FunctionComponent;
export import createContext = preact.createContext;
export import Ref = preact.Ref;
export import createRef = preact.createRef;
export import Fragment = preact.Fragment;
export import createElement = preact.createElement;
Expand Down
4 changes: 4 additions & 0 deletions compat/test/ts/forward-ref.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ export const Bar = React.forwardRef<HTMLDivElement, { children: any }>(
return <div ref={ref}>{props.children}</div>;
}
);

export const baz = (
ref: React.ForwardedRef<HTMLElement>
): React.Ref<HTMLElement> => ref;