Proposal (breaking change): remove inputProps from Input, TextField, etc.
See original GitHub issueThe Input
component has both
inputComponent?: React.ReactNode;
and
inputProps?:
| React.TextareaHTMLAttributes<HTMLTextAreaElement>
| React.InputHTMLAttributes<HTMLInputElement>;
The first thing to note is that the type for inputComponent
is wrong, it should be
inputComponent?: string | React.ComponentType<...>;
where ...
is whatever properties could actually be passed down by the parent component to the child component. That brings us to inputProps
. What are they here for? If you look at most other components, for example Button
, there is no prop like this, only
component?: string | React.ComponentType<ButtonProps>;
and the way you would inject whatever custom props your overriding component needs would be
<Button component={buttonProps => <MyButton {...buttonProps} myCustomProp={3} />} />
So why isn’t Input
the same way, and do we really need the inputProps
prop? Besides consistency with the rest of the code base, a good reason not to have inputProps
is that it’s impossible to make type safe. We basically have to say
inputComponent?: string | React.ComponentType<any>;
inputProps?: any;
So I’d like to advocate removing inputProps
and instead having a closed set of specified props that Input
can pass to inputComponent
.
See also #9313.
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (14 by maintainers)
Top GitHub Comments
Not a bad idea. We should probably highlight the structure of it and point to the underlying components. I think a literal display of source structure might be useful, all under a header like “Advanced Configuration”
As an aside, with this change,
inputComponent
looks like it will be redundant, and just needcomponent
like others.