reactjs - Integrate react-datepicker with redux-form -
following code create datepicker field
<div classname='control mb-30'> <field name='disc_redemption_start_date' component={datepickercustom} label='discount redemption start date' dateformat="do mmm yyyy" mindate={moment()} selected={new date()} /> </div>
then have created component datepicker following:
datepickercustom.js
import react 'react'; import datepicker 'react-datepicker'; import moment 'moment'; const datepickercustom = ({input, placeholder, mindate, dateformat, defaultvalue, selected, meta: {touched, error} }) => ( <div> <datepicker {...input} dateformat={dateformat} mindate={mindate} selected={input.value ? input.value : null} /> {touched && error && <span classname='help is-error'>{error}</span>} </div> ); export default datepickercustom;
the issue that, when change date in datepicker , check form values values.get('disc_redemption_start_date'), first moment object click outside datepicker, value gets updated string of date in format 'do mm yyyy' due not able convert string iso date format.
i need moment object , not string pass api.
Comments
Post a Comment