diff --git a/README.md b/README.md index 9fa6f4d..4ead182 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,19 @@ Dead simple Object schema validation. [![npm](https://img.shields.io/bundlephobia/minzip/yup?style=for-the-badge)](https://bundlephobia.com/result?p=yup) +> ⚠️ Pass context via `useForm({ context })`, not via `yupResolver`'s `schemaOptions`. `schemaOptions.context` is overridden by the form context, so use the `useForm` context object instead. + +```typescript jsx +// Correct +useForm({ + resolver: yupResolver(schema), + context: { foo: true }, +}); + +// Avoid - schemaOptions.context will be ignored/overridden +yupResolver(schema, { context: { foo: true } }); +``` + ```typescript jsx import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup';