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

input DX improvement opportunity #12710

Closed
oliviertassinari opened this issue Apr 28, 2018 · 3 comments
Closed

input DX improvement opportunity #12710

oliviertassinari opened this issue Apr 28, 2018 · 3 comments

Comments

@oliviertassinari
Copy link
Contributor

oliviertassinari commented Apr 28, 2018

Do you want to request a feature or report a bug?

A feature

What is the current behavior?

No warning is raised in the following snipped:

import React from "react";

export default class TextFields extends React.Component {
  state = {
    name: "Before timeout"
  };

  componentDidMount() {
    // emulate loading some data with AJAX
    setTimeout(() => {
      console.log("Updating name after timeout");
      this.setState({
        name: "After timeout"
      });
    }, 100);
  }

  render() {
    return <input id="name" label="Name" defaultValue={this.state.name} />;
  }
}

https://codesandbox.io/s/k248z9ro15

What is the expected behavior?

I believe we have the opportunity to raise a warning in development. It would inform users they can't update the defaultValue property. This problem was raised to my attention in mui/material-ui#11150.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

React 16.3.2

@jquense
Copy link
Contributor

jquense commented Apr 28, 2018

I see how this is generally a bug in this case however defaultValue can be updated to some effect, since it's the value used as the fallback in some situations, like a form reset

@oliviertassinari
Copy link
Contributor Author

@jquense Alright, does it mean there is no DX improvement opportunity? Should we close this issue?

@gaearon
Copy link
Collaborator

gaearon commented Apr 28, 2018

Yeah I think we can’t warn without legit false positives.

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

3 participants