Update Formik Initial Values When Props Change
const ZipForm = ({ currentZip }) => {
return (
<Formik
initialValues={{ zip: currentZip }}
onSubmit={(values, actions) => {
// do stuff
}}
...const ZipForm = ({ currentZip }) => {
return (
<Formik
initialValues={{ zip: currentZip }
enableReinitialize
onSubmit={(values, actions) => {
// do stuff
}}
...PreviousTrigger Effect Only When The Component MountsNextUpgrading To The Latest React In CodeSandbox
Last updated