Skip to content

Add statics to forwardRef #1475

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

Merged
merged 3 commits into from
Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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 generatedTypes/src/commons/forwardRef.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export interface ForwardRefInjectedProps {
*/
forwardedRef: any;
}
export default function forwardRef<P = any>(WrappedComponent: React.ComponentType<P>): React.ComponentType<P>;
export default function forwardRef<P = any, STATICS = {}>(WrappedComponent: React.ComponentType<P>): React.ComponentType<P> & STATICS;
3 changes: 1 addition & 2 deletions src/commons/forwardRef.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface ForwardRefInjectedProps {
forwardedRef: any;
}

export default function forwardRef<P = any>(WrappedComponent: React.ComponentType<P>): React.ComponentType<P> {
export default function forwardRef<P = any, STATICS = {}>(WrappedComponent: React.ComponentType<P>): React.ComponentType<P> & STATICS {
function forwardRef(props: P, ref: any) {
return <WrappedComponent {...props} forwardedRef={ref}/>;
}
Expand All @@ -24,4 +24,3 @@ export default function forwardRef<P = any>(WrappedComponent: React.ComponentTyp

return ForwardedComponent as any;
}