0
私はGoogle APIのAPI呼び出しを行っています。何らかの理由により、減速器が起動すると、コンポーネントの状態はクリアされ、入力フィールドは空白になります。これは、減速機が点火するときにのみ起こるように見える。私はちょうどthis.setState何もクリア...リダクターが起動して誤って入力がクリアされる
ここに私の入力コンポーネントです。あなたの減速が発射された場合、ここで
constructor(props) {
super(props)
this.state = {
address: '',
}
}
handleKeyPress = (e) => {
if (e.key === 'Enter') {
this.getCordinates()
}
}
onChange = (e) => {
this.setState({address: e.target.value})
}
getCordinates = (latLng) => {
this.props.callTimeZoneAPI(lat,lng)
}
render() {
return (
<input type="text"
className="location_input"
onChange={this.onChange}
value={this.state.address}
onKeyPress={this.handleKeyPress}
/>
は私の減速
const initStateOfTimeZones = {
TimeZones: [],
Times: [],
Date: []
}
switch(type){
case ADD_TIME_ZONE:
return assign({}, state, {
TimeZones: payload
});
default:
return state