question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get touched and errors props into Wizard.Page from Formik Multistep example

See original GitHub issue

📖 Documentation

I think the Multistep example is one of most used use cases for Formik and quite elegant. Before I rewrite the whole thing, probably somebody can help: I wrapping my head around how to get the touched and errors props from Formik into the Wizard page. I don’t want to use the ErrorMessage Component because one of my own components within Wizard.Page relies on touched and errors from <Formik />.

What I tried: Adding touched and errors as args in Formik render prop in line 62: https://github.com/jaredpalmer/formik/blob/344b846bc25865dc02b6304e7c9f447b5b1552fd/examples/MultistepWizard.js#L62 but I don’t know how to access it within Wizard.Page, e.g. like this:

<Wizard.Page>
  {props => (
    <MyCustomField errors={props.error} touched={props.touched} />
  ...

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
johnromcommented, Jul 31, 2019

Yep, that’s the same as using useFormikContext, except Field does it for you. You can also use (for thoroughness’ sake):

const MyCustomField = props => {
    const [field, meta] = useField(props.name);

    return <input name={field.name} className={meta.error ? "input-error" : ""} />;
}
0reactions
johnromcommented, Aug 2, 2019

Np, I’m closing this in favor of #1725

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building multi-step wizards with Formik and React Query
Learn how to build multi-step wizards in a small proof-of-concept application with Formik and React Query right here.
Read more >
Formik Multi-Step Form with Material UI | React JS ... - YouTube
In this video we explore how to create a multi-step form ( wizard ) in ReactJS using the Formik 2 library, Material UI,...
Read more >
Build a multi-step form with React Hooks, Formik, Yup and ...
Let's go through the code we've just added. · The component is initialized with the default value for step in state as 0,...
Read more >
Access values from previous step using Formik Wizard
You can use React context or Redux for this purpose. Here's how to do it with React Context. Step1: Create a "provider" which...
Read more >
Tutorial - Formik
Learn how to build forms in React with Formik. ... Getting values in and out of form state; Validation and error messages; Handling...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found