我正在使用 TypeScript(v4.2.3)和 Material UI(v4.11.3),并尝试将自定义道具传递给styled组件。
import React from 'react';
import {
IconButton,
styled,
} from '@material-ui/core';
const NavListButton = styled(IconButton)(
({ theme, panelOpen }: { theme: Theme; panelOpen: boolean }) => ({
display: 'inline-block',
width: 48,
height: 48,
borderRadius: 24,
margin: theme.spacing(1),
backgroundColor: panelOpen ? theme.palette.secondary.dark : 'transparent',
}),
);
...
const Component: React.FC<Props> = () => {
return (
<NavListButton panelOpen={true} />
);
};
Run Code Online (Sandbox Code Playgroud)
这工作正常,但如果我检查控制台,它会遇到错误。
Warning: React does not recognize the `panelOpen` prop on a DOM element. If …Run Code Online (Sandbox Code Playgroud) 如何在不使用以下代码的情况下隐藏/删除TextField组件中的下划线:
const theme = createMuiTheme({
overrides: {
MuiInput: {
underline: {
'&:hover:not($disabled):before': {
backgroundColor: 'rgba(0, 188, 212, 0.7)',
},
},
},
},
});
Run Code Online (Sandbox Code Playgroud)
我想用道具并根据文档来做:https://material-ui.com/api/input/
我应该能够改变下划线道具,但它不起作用.