input DX improvement opportunity
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-org/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
推荐相似问题
The `ref.current` point to the wrong dom node
eg: {this.state.a ? <div ref={this.myRef} className="a"/> : <div className="b"/>} after state.a was set to false,when ac
* { all: initial; } in css is breaking the react app
Hey guys, I have one problem working with any and even simple app of react. Here is the link of jsfield https://jsfiddle
Coverage Support for JSX-Control-Statements
Conditional Rendering Components JSX-Control-Statement produces incorrect coverage in if / else branches. We are using i
onClick event is not firing after enabling button via ref
Do you want to request a feature or report a bug? possible Bug, needs investigation What is the current behavior? When h
Type is invalid. You likely forgot to export your component from the file it's defined in
I posted a SO question and created an issue on the Voyager project but thought I'd also document it here. I'm using comp
Feature request: get a ref of a in memory dom element before mount.
Do you want to request a feature or report a bug? Feature What is the current behavior? currently, there isn't a great w
Calling ReactDOM.render() many many times is slow
Do you want to request a feature or report a bug? Bug (?) What is the current behavior? Calling ReactDOM.render() many m
Styles via className not reflected in print
Do you want to request a feature or report a bug? Not 100% sure, but might be a bug (or just something I'm not doing rig
Conditional Rendering Such as JSX-Control-Statements
Do you want to request a feature or report a bug? Neither Conditional Rendering Components like JSX-Control-Statement ht
Ref callback is not called before componentDidMount
Do you want to request a feature or report a bug? Bug What is the current behavior? ref callback is not executed before
基本信息
- 回复数:329
- 讨论框架:react
- 原始内容:查看信息
- 最后更新于:2020-10-23
相关讨论
- 1. Render children at most once through the use of Singletons
- 2. Bug: React function component unmounts on state change.
- 3. Bug: SuspenseList revealOrder="backwards" is not consistent without tail props
- 4. Bug: disableRemotePlayback not recognized
- 5. Bug: react test utils do not work together with esm module
3条回答
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
@jquense Alright, does it mean there is no DX improvement opportunity? Should we close this issue?
Yeah I think we can’t warn without legit false positives.