Created
January 9, 2019 23:23
-
-
Save Faliszek/d6e0927cec70f9d6fcd088306c29f1a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Formik } from 'formik'; | |
import moment from "moment" | |
//Jezeli np bylaby zmiana formatu daty, powiedzmy komponent zwraca moment, | |
//a chcialbys DD.MM.YYYY - i taka wartosc ostatecznie wpadnie do twoich values | |
function formatDate(momentDate) { | |
return moment(momentDate).format("DD.MM.YYYY") | |
}; | |
const MyComponent = props => ( | |
<Formik> | |
{(renderProps) => { | |
//Tu z renderProps mozesz wziac wszystko co formik ma dozaoferowania | |
// min. values, errors | |
const { setFieldValue } = renderProps; | |
return( | |
<form> | |
<DatePicker | |
onChange={dateValueFromMyDatePicker => | |
setFieldValue("datePickerValue", formatDate(dateValueFromMyDatePicker))} | |
/> | |
</form> | |
) | |
}} | |
</Formik> | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment