Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't setState inside onChange function #4

Closed
katp4 opened this issue Jan 31, 2019 · 1 comment
Closed

Can't setState inside onChange function #4

katp4 opened this issue Jan 31, 2019 · 1 comment

Comments

@katp4
Copy link

katp4 commented Jan 31, 2019

Hello,

I'm trying to use this but i'm getting an irrational error. First of all, setting the state of anything throws the below errors (see screenshots) and even if that works, i'm unable to use the "value" property to make it a controlled input as it somehow picks it up itself. i would appreciate your input.

@material-ui/core "version": "3.9.0"
react "version": "16.7.0"

image

Please see my code below;

<FormControl fullWidth={true} className={classes.formControl}>
                                            <InputLabel className={classes.formControl} htmlFor="phoneNumber">Phone
                                                Number
                                            </InputLabel>
                                            <ReactPhoneInput
                                                regions={["europe", "oceania"]}
                                                name="phone"
                                                onChange={this.handleOnChange.bind(this)}
                                                required={true}
                                            />
                                            <Typography align="left" paragraph={true} variant="subtitle2" color="textPrimary" className={classes.smallBlueFont}>{this.state.errors.phone}</Typography>
                                        </FormControl>

where handleOnChange is

handleOnChange(countryCode, value) {
         console.log(1,value, countryCode)

         this.setState({ anything: true})

     }
@katp4 katp4 closed this as completed Feb 12, 2019
@alexplumb
Copy link
Owner

Hi @katp4 sorry for the delay in getting to this - is this still an issue or were you able to fix it?

bherila pushed a commit that referenced this issue Aug 29, 2021
bherila pushed a commit that referenced this issue Aug 29, 2021
david-vendel referenced this issue in david-vendel/material-ui-phone-number-2 May 18, 2022
…ack-5.71.0

Bump webpack from 5.58.1 to 5.71.0
ziktar pushed a commit to ziktar/material-ui-phone-number that referenced this issue Jun 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants