让我们说FieldGroup是一个纯组件。
import FieldGroup from '../components/FieldGroup';
class InputThatWorks extends Component {
...
// the React render method
render () {
const { fields } = this.state;
return (
<h1>First field group</h1>
<FieldGroup
type="text"
id="username"
label="Field One:"
name="one"
value={fields.one}
onChange={this._handleChange}
/>
<h1>Second field group</h1>
<FieldGroup
type="text"
id="username"
label="Field Two:"
name="two"
value={fields.two}
onChange={this._handleChange}
/>
);
}
}
FieldGroup会在每个“ InputThatWorks”渲染器上重新渲染,因为在每个渲染器上声明了一个用于设置道具的新const吗?我能正确理解吗?