我正在尝试按如下方式使用 airbnb react-dates:
function NewEntryModal(props) {
return <Formik
initialValues={{}}
onSubmit={(values, actions) => {
}}
render={props => (
<form onSubmit={props.handleSubmit}>
<SingleDatePicker
date={props.date} // momentPropTypes.momentObj or null
onDateChange={date => props.setDate({ date })} // PropTypes.func.isRequired
focused={props.focused}
onFocusChange={(focused) => props.setIsFocused(focused)}
id="string" // PropTypes.string.isRequired,
/>
<button type="submit">Submit</button>
</form>
)}
/>
}
export default compose(
withState('isFocused', 'setIsFocused', false),
withState('date', 'setDate', moment()),
)(NewEntryModal);
我正在使用recompose withState
来更新日期和焦点状态。但是,我收到一个错误,说这setIsFocused
不是一个函数。
任何反馈将不胜感激。