value gives [object Object] if inputComponnent={Input} and this Input is imported from "@material-ui/core"
See original GitHub issue<PhoneInput
inputComponent={TextField}
limitMaxLength
value={phone}
onChange={value => this.handlePhone(value)}
error={phone ? (isValidPhoneNumber(phone) ? undefined : 'Invalid phone number') :
'Phone number required'}
/>
Neither TextField not Input from material-ui/core works fine. Your component works perfectly fine but when we use Input from material-ui, it starts giving [object Object] in value where expected value is the entered phone number. Please help!
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
OutlinedInput API - Material UI - MUI
API reference docs for the React OutlinedInput component. ... If true , the input element is focused during the first mount. classes, object....
Read more >React Text Field component - Material UI - MUI
The TextField wrapper component is a complete form control including a label, input, and help text. It comes with three variants: outlined (default), ......
Read more >FormControl API - Material UI - MUI
API reference docs for the React FormControl component. ... Provides context such as filled/focused/error/required for form inputs. ... classes, object.
Read more >InputAdornment API - Material UI - MUI
API reference docs for the React InputAdornment component. Learn about the props, CSS, and other APIs of this exported module.
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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@TylerRick
And I finally figured out that indeed
inputComponent
isn’t what I initially thought it was when replying in this issue. Lol. Indeed, just swappinginputComponent
isn’t enough. I’ve added a newnumberInputComponent
property — this one is swappable and could be set to a Material UI input or whatever else.Released
react-phone-number-input@2.3.25
with thenumberInputComponent
property.Thank you so much for your reply and suggested workaround. I don’t think we even need to simulate an event though.
I finally found the solution to this problem (getting
[object Object]
as the value) that @mghazanfar and I were having, in the comments on #226: @NevenLiang had a good example of an adapter component that adapts between the API of TextField and the API required by PhoneInput’sinputComponent
, which solves this and a few other issues (like the need to implementinput.focus
)I’ve created a sandbox demo here: https://codesandbox.io/s/integrate-react-phone-number-input-with-material-uicore-ohfwp
The next major pain point with using material-ui is that there doesn’t appear to be a way to pass props down to the input component. I’m suggesting we add one in issue #280.
It’s a string. Something is coercing the Event object into the string,
"[object Object]"
.