0
datePickerAndroid
を使用して以降の状態を設定しようとすると、このエラーが発生します。TypeError:予想される動的タイプ 'double' 'type' string '
問題は、初期状態がnew Date()
ではなく、100%確認されてからのものであってもよいような気がします。
_isAndroid = async() => {
let {action, year, month, day} = await DatePickerAndroid.open({
date: this.props.startDate,
});
if (action === DatePickerAndroid.dismissedAction) {
this.props.closeModal()
} else {
const date = year + "-" + month + "-" + day
this.props.onDateChange(date)
}
}
Prop Function:
onDateChange = (newDate) => {
this.setState({currentDate: newDate}) // <- This one is breaking
let dates = this.state.dates;
let index = this.state.currentIndex;
if (this.state.currentKey === "start") {
dates[index].start = newDate
} else {
dates[index].end = newDate
}
this.setState({dates: dates});
}
私が最初setState
にそれを絞り込むきた、と私は初期状態に文字列を作るだけでなく、単純な文字列に状態を設定するが、まだエラーを取得しようとしました。言い換えればDatePickerAndroid
expected dynamic type double
については
ミリ秒が予想されますか?newDate.getTime()? – jcuenod
これはどのコード行ですか? – wallyk
'this.setState({currentDate:newDate})' – jcuenod