question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal (breaking change): remove inputProps from Input, TextField, etc.

See original GitHub issue

The 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:closed
  • Created 6 years ago
  • Comments:15 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
rosskevincommented, Dec 15, 2017

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”

1reaction
rosskevincommented, Nov 29, 2017

As an aside, with this change, inputComponent looks like it will be redundant, and just need component like others.

Read more comments on GitHub >

github_iconTop Results From Across the Web

remove inputProps from Input, TextField, etc. · Issue #9326 ...
The Input component has both inputComponent?: React. ... Proposal (breaking change): remove inputProps from Input, TextField, etc. #9326.
Read more >
Applying InputAdornment to MUI AutoComplete removes the ...
If I remove the InputProps from <TextField /> like so: <Autocomplete freeSolo size="small" id="filter-locks-autocomplete" options={json_list ...
Read more >
material-ui/core/CHANGELOG.md - UNPKG
The Tabs `fullWidth` and `scrollable` properties can't be used at the same time. The API change prevents any awkward usage. 22.
Read more >
Breaking changes in v5, part two: core components - Material UI
This is a reference guide to all of the breaking changes introduced in Material v5, and how to handle them when migrating from...
Read more >
TextInput - React Native
A foundational component for inputting text into the app via a keyboard. Props provide configurability for several features, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found