Аргумент типа x не назначается параметрам типаJavascript

Форум по Javascript
Ответить
Anonymous
 Аргумент типа x не назначается параметрам типа

Сообщение Anonymous »

Я пытаюсь обновить старый компонент React с помощью TypeScript и MUI: https://github.com/yuvaleros/material-u ... oneобразно Br />

Код: Выделить всё

 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
Спасибо

Подробнее здесь: https://stackoverflow.com/questions/794 ... enderfunct
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Javascript»