为什么受控输入更改时 PureComponent 不呈现
更改为 Component 解决了它
import React, { PureComponent } from 'react';
class Contact extends PureComponent {
state = {firstName:''}
handleInput = ({ target }, name) => {
const state = this.state;
state[name] = target.value;
this.setState(state);
};
render(){
return (
<input onChange={e => {
this.handleInput(e, 'firstName');
}}
value={this.state.firsName} />
)
}
}
它应该在打字时呈现新状态,但它没有