我正在使用MUI和typescript,并面临以下错误。我怀疑,我在这里错过了一种非常基本的东西,但又无法捕捉到它。 Error: Type 'Color' is not assignable to type '"default" | "primary" | "secondary"'. 我使用的是Chip in loop。https://material-ui.com/components/chips/ 这里是沙箱:https://codesandbox.io/s/material-demo-forked-7g6
我很难输入下面的动态按钮组件,它可以处理链接或onClick事件。这是我现在尝试重构为TypeScript的组件的一个简化片段。
import React from 'react'
import { Link } from 'react-router-dom'
type Props = {
children: React.ReactNode,
} & (
{
to: string,
type: undefined,
onClick: undefined,
} | {
to: undefined,
ty
我想使用原生Material-ui组件,但在浏览器中出现以下错误:
index.js:2178警告:属性类型失败:属性children在AppBar中被标记为required,但其值为undefined。
我的组件是:
import React from 'react';
import AppBar from 'material-ui/AppBar';
/**
* A simple example of `AppBar` with an icon on the right.
* By default, the left icon is a navigati
我在react中使用ts。如何将路径链接添加到我的代码中的选项卡 import React from 'react';
import { makeStyles, Theme } from '@material-ui/core/styles';
import AppBar from '@material-ui/core/AppBar';
import Tabs from '@material-ui/core/Tabs';
import Tab from '@material-ui/core/Tab';
import
我们为material-ui@next创建了类型,并希望将它们与库一起发送,这是我们在上一个测试版中所做的。
下面是指向的链接。
但是,这些类型在当前的形式中是不可用的。在开发中,它们在本地使用并且工作良好,但是当将文件与库一起传送时,TypeScript似乎使用了不同的发现策略。
引用子文件夹(例如declare 'material-ui/Button/Button')的所有类型都不会是TypeScript。当导入组件时,会出现一个错误:
[ts]
Could not find a declaration file for module 'material-ui/Bu
我正在使用Jest + RTL为一个简单的React组件创建一个测试。 这是我的组件: import React from 'react';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import Grid from '@mat
我觉得我做的都错了。Typescript试图告诉我要做什么?我在这里玩变态游戏
TypeScript error in /Users/alex-wilmer/Projects/resideo/pro-portal/packages/web/src/utils/feature-flags/index.tsx(46,9):
Type 'Dispatch<SetStateAction<{ OCT19_DEMO: undefined; }>>' is not assignable to type '() => void'. TS2322
我试图解决一个npm审计问题,其中加载程序-使用程序和用户是造成问题的角14应用程序,我正在维护。
问题是:
我试过:
在解决方案下,我添加了"terser“和”加载器-utils“,然后运行npx npm-force-resolutions。
因此,现在我没有审计问题,但该项目将不会建立:
[error] TypeError: Ajv is not a constructor
at Object.<anonymous> (C:\Projects\scenic.booking.portal.ui\node_modules\mini-css-extract-plugi
我一直在尝试创建一个实用函数来包装React测试库的render函数,该函数使用Router来包装整个React元素。代码如下所示。 import { ReactElement } from 'react';
import { render as renderRTL } from '@testing-library/react';
import { Router } from 'react-router-dom';
import { createMemoryHistory, History } from 'history';
长话短说,打字稿抱怨每个材料ui组件上缺少的property classes。换句话说,类型记录强制将属性存在于几乎所有的材料ui组件中。下面是webpack使用ts-loader编译过程中的错误信息,
我有以下密码,
Header.tsx
import AppBar from 'material-ui/AppBar';
import * as React from 'react';
import { withStyles } from 'material-ui/styles/index';
import Toolbar from 'ma
获取JSX element type 'Route' does not have any construct or call signatures,同时尝试使用TypeScript跟踪本演练。
我的代码:
const Routes = (
<Route path="/" handler={Main}>
<IndexRoute handler={ConnectionModule} />
</Route>
);
导致TypeScript编译器使用上述错误消息抱怨路由和IndexRount导入。
以下是我的导入语句(
试图使用材料Ui实验室的复选框。但是,在npm安装了三个依赖项:@material-ui/lab、@material-ui/core和@material-ui/icons之后,我收到了以下错误:
./node_modules/@material-ui/core/esm/Portal/Portal.js Attempted import error: 'HTMLElementType' is not exported from '@material-ui/utils'.
我的进口商品如下:
import React from 'react';
im
我对TypeScript很陌生,并试图了解如何将React代码转换为被键入的代码。目前,我得到了以下错误:
Property 'openMenu' does not exist on type '{ children?: ReactNode; }'
Property 'toggle' does not exist on type '{ children?: ReactNode; }'
Property 'slidein' does not exist on type '{ children?: ReactN
我对这种技术组合非常陌生: React/Typescript/Material UI。
我只发现了一个与Material-UI一起使用hover的类似问题,但是语法有很大的不同,因为React代码没有使用Typescript。你可以在这里找到这个:
我正在试图找出一种方法,利用Material-UI纸张组件对JSS的内置支持,将hover属性添加到Material-UI纸张组件中。
我得到的错误是:Material-UI: the key .Component-root-199:hover provided to the classes property object is not imple
我正在为typescript中的react应用程序使用material-ui。material-ui提供了withStyles,它通过className注入到组件中。但是我不知道如何声明它的类型。下面是一个示例代码:
import * as React from 'react';
import Grid from '@material-ui/core/Grid';
import { withStyles, createStyles } from '@material-ui/core/styles';
const BackgroundPanelS
我的react项目中有这个错误输出
TypeScript error
Argument of type 'ReactNode' is not assignable to parameter of type 'ReactElement<any, string | JSXElementConstructor<any>> | ReactElement<any, string | JSXElementConstructor<any>>[]'.
Type 'undefined' is not assign