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 };
Я новичок в TypeScript, поэтому исправление выпуска TSC жестко: s
Спасибо
Я пытаюсь обновить старый компонент React с помощью TypeScript и MUI: https://github.com/yuvaleros/material-ui-pro-dropzoneобразно Br />[code] 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";