TextFieldProps
ではなく、StandardTextFieldProps
を使用する。
Cannot pass underline class through TextField as InputProps · Issue #13794 · mui/material-ui
import React from 'react' import { TextField, TextFieldProps } from '@material-ui/core' type Props = TextFieldProps & { classes: Record<string, string> } export function renderInput(inputProps: Props) { const { InputProps } = inputProps return ( // 👇 TypeError <TextField InputProps={{ classes: { underline: classes.inputUnderline, }, }} /> ) }
import React from 'react' // 👇 StandardTextFieldProps に変更 import { TextField, StandardTextFieldProps } from '@material-ui/core' type Props = StandardTextFieldProps & { classes: Record<string, string> } export function renderInput(inputProps: Props) { const { InputProps } = inputProps return ( <TextField InputProps={{ classes: { underline: classes.inputUnderline, }, }} /> ) }