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

Got warning: Failed prop type: Invalid prop value supplied to TextField #11994

Closed
RyanZhu1024 opened this issue Jun 28, 2018 · 4 comments
Closed
Labels
duplicate This issue or pull request already exists

Comments

@RyanZhu1024
Copy link

I got an error when from console when rendering the TextField.

Warning: Failed prop type: Invalid prop valuesupplied toTextField.

I saw there are 2 relevant issues in the list:

#2250
#2423

But their console provide more detailed info like type while mine doesn't have it.

Below is the code:

  constructor(props) {
    super(props);
    const { property } = props;
    this.state = { value: property.value };
  }
          <TextField
            id={this.props.property.name}
            label={this.props.property.name}
            className={classes.textField}
            value={this.state.value}
            onChange={this.handleChange}
            margin="normal"
          />

In the code, value is initialized as an empty string.

What I can't understand is if I initialized the value as undefined, no more warning. However, empty string doesn't work.

Any thoughts on it?

@RyanZhu1024 RyanZhu1024 changed the title Got warningI nvalid prop value supplied to TextField Got warning: Failed prop type: Invalid prop value supplied to TextField Jun 28, 2018
@arjunagl
Copy link

I tried by simply providing an empty string with the following and did not get any warning

<TextField id="time" value="" />

Maybe I'm missing something, but above is what I tried.

@oliviertassinari oliviertassinari added the duplicate This issue or pull request already exists label Jun 28, 2018
@oliviertassinari
Copy link
Member

I'm closing as a duplicate of facebook/prop-types#9. It's a type of issue we have already seen in #10845. Make sure your value is valid.

@RyanZhu1024
Copy link
Author

Thanks. I'll follow

@vinyoliver
Copy link

@RyanZhu1024 have you been able to solve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants