jaredpalmer / formik-persist

💾 Persist and rehydrate a Formik form to localStorage
MIT License
377 stars 56 forks source link

add confirm option, if user wants to choose if rehydrate or not #39

Open ZhihaoLau opened 3 years ago

ZhihaoLau commented 3 years ago

This PR adds an optional confirm property. When set, the form state will be rehydrate or not, depends on what boolean value of confirm function being resolve: usage:

<Persist
        name={formName}
        confirm={async () => {
          const action = await ResolvableMessageBox({
            desc: 'There're unsaved changes since you leave last time, recover?'
          })
          return action === 'confirm';
      }}
/>