Skip to content

Commit

Permalink
Add displayName to FormikContext (jaredpalmer#2962)
Browse files Browse the repository at this point in the history
Right now the context doesn't have a displayName, and the default name for a context is just "Context" so in an app with a lot of contexts we end up with several items in the devtools call `<Context.Provider>` and `<Context.Consumer>`

![image](https://user-images.githubusercontent.com/709773/102159836-2e4c8180-3ee9-11eb-82b9-b97fc1e5d199.png)

this PR will make the formik ones display as

`<FormikContext.Provider>` and `<FormikContext.Consumer>`

![image](https://user-images.githubusercontent.com/709773/102159868-42907e80-3ee9-11eb-83b2-822ea842464a.png)

This also has the added benefit of making it easier to quickly locate the Formik context when using the component search.
  • Loading branch information
hailwood authored Dec 17, 2020
1 parent 83ea3ed commit 750ded5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/formik/src/FormikContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import invariant from 'tiny-warning';
export const FormikContext = React.createContext<FormikContextType<any>>(
undefined as any
);
FormikContext.displayName = 'FormikContext';

export const FormikProvider = FormikContext.Provider;
export const FormikConsumer = FormikContext.Consumer;

Expand Down

0 comments on commit 750ded5

Please sign in to comment.