Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: Proxy to defineProperty in ApiFormState #909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
fenderil wants to merge 1 commit into react-hook-form:master
base: master
Choose a base branch
Loading
from fenderil:patch-1
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/ApiFormState.tsx
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ export default React.memo(
<p>
<code>formState</code> is wrapped with a{" "}
<a
href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy"
href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty"
target="_blank"
rel="noopener noreferrer"
>
Proxy
defineProperty's <code>get</code> descriptor
</a>{" "}
to improve render performance and skip extra logic if specific
state is not subscribed to. Therefore make sure you invoke or read
Expand Down Expand Up @@ -71,7 +71,7 @@ export default React.memo(

<CodeArea
rawData={`// ❌ formState.isValid is accessed conditionally,
// so the Proxy does not subscribe to changes of that state
// so the formState with get descriptor does not subscribe to changes of that state
return <button disabled={!formState.isDirty || !formState.isValid} />;

// ✅ read all formState values to subscribe to changes
Expand Down

AltStyle によって変換されたページ (->オリジナル) /