Код: Выделить всё
error TS2345: Argument of type '(props: WithoutTheme
, ref: any) => Element' is not assignable to parameter of type 'ForwardRefRenderFunction'.
Types of parameters 'props' and 'props' are incompatible.
Type 'PropsWithoutRef' is not assignable to type 'WithoutTheme'.
Type '{ theme?: Theme | undefined; }' is not assignable to type 'WithoutTheme'.
return forwardRef(function ComponentWithTheme(
< /code>
on < /p>
import type { Theme } from "@mui/material/styles";
import { useTheme } from "@mui/material/styles";
import type { ComponentType } from "react";
import React, { forwardRef } from "react";
type WithoutTheme = Omit;
function withTheme(Component: ComponentType) {
return forwardRef(function ComponentWithTheme(
props: WithoutTheme,
ref: any,
) {
const theme = useTheme();
const combinedProps = { ...props, theme } as P;
return ;
});
}
export { withTheme };
Спасибо
Подробнее здесь: https://stackoverflow.com/questions/794 ... enderfunct