From de6ee52c333d6a425e0c53cbc66297357a5471a9 Mon Sep 17 00:00:00 2001 From: eotkd4791 Date: Sun, 25 Jan 2026 23:49:59 +0900 Subject: [PATCH 1/3] docs: clarify yupResolver context usage in README --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 9fa6f4d..8b53c67 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`. Using React state/atoms via `schemaOptions.context` can result in stale/undefined values. + +```typescript jsx +// Correct +useForm({ + resolver: yupResolver(schema), + context: { foo: true }, +}); + +// Avoid - context will be stale/undefined +yupResolver(schema, { context: { foo: true } }); +``` + ```typescript jsx import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; From 402df6f88eff6c5db626fddcc78573bd736015ae Mon Sep 17 00:00:00 2001 From: eotkd4791 Date: Mon, 26 Jan 2026 01:44:43 +0900 Subject: [PATCH 2/3] fix: ambigious expression --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8b53c67..e9fb1b4 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ 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`. Using React state/atoms via `schemaOptions.context` can result in stale/undefined values. +> ⚠️ Pass context via `useForm({ context })`, not via `yupResolver`'s `schemaOptions`. Using React state/atoms via `schemaOptions.context` can result in `undefined` values. ```typescript jsx // Correct From 822545b416ded8159c4da530ec8c76b5e6681fc9 Mon Sep 17 00:00:00 2001 From: eotkd4791 Date: Sun, 5 Apr 2026 05:15:53 +0900 Subject: [PATCH 3/3] docs: clarify yup context override --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e9fb1b4..4ead182 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ 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`. Using React state/atoms via `schemaOptions.context` can result in `undefined` values. +> ⚠️ 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 @@ -156,7 +156,7 @@ useForm({ context: { foo: true }, }); -// Avoid - context will be stale/undefined +// Avoid - schemaOptions.context will be ignored/overridden yupResolver(schema, { context: { foo: true } }); ```