Skip to content
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

fix: Proxy to defineProperty in ApiFormState #909

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
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