Skip to content

Commit 29b3dab

Browse files
fix(ts): Fix TypeScript errors in withAPIContext
Co-Authored-By: Joseph Gross <[email protected]>
1 parent 1eb0d66 commit 29b3dab

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/elements/common/api-context/withAPIContext.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@ import APIContext from './APIContext';
88

99
export interface WithAPIProps {
1010
api?: API | null;
11-
[key: string]: unknown;
1211
}
1312

14-
const withAPIContext = <P extends WithAPIProps, T = unknown>(WrappedComponent: React.ComponentType<P>) => {
15-
return React.forwardRef<T, Omit<P, 'api'>>((props, ref) => (
16-
<APIContext.Consumer>{api => <WrappedComponent ref={ref} {...(props as P)} api={api} />}</APIContext.Consumer>
13+
/**
14+
* Higher-order component that provides API context to the wrapped component
15+
* This HOC is used by many components throughout the codebase
16+
*/
17+
const withAPIContext = (
18+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
19+
WrappedComponent: React.ComponentType<any>,
20+
) => {
21+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
22+
return React.forwardRef<any, any>((props, ref) => (
23+
<APIContext.Consumer>{api => <WrappedComponent ref={ref} {...props} api={api} />}</APIContext.Consumer>
1724
));
1825
};
1926

0 commit comments

Comments
 (0)