Skip to content

Commit

Permalink
fix: wrap set state with array expression (#1079)
Browse files Browse the repository at this point in the history
  • Loading branch information
rtpascual authored Aug 17, 2023
1 parent 58a475c commit 5c73726
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1706,7 +1706,7 @@ export default function MyMemberForm(props) {
: \\"\\"
);
setCurrentTeamIDValue(value);
setSelectedTeamIDRecords(teamIDRecords.find((r) => r.id === value));
setSelectedTeamIDRecords([teamIDRecords.find((r) => r.id === value)]);
}}
inputFieldRef={teamIDRef}
defaultFieldValue={\\"\\"}
Expand Down Expand Up @@ -4018,7 +4018,7 @@ export default function CommentCreateForm(props) {
: \\"\\"
);
setCurrentPostIDValue(value);
setSelectedPostIDRecords(postIDRecords.find((r) => r.id === value));
setSelectedPostIDRecords([postIDRecords.find((r) => r.id === value)]);
}}
inputFieldRef={postIDRef}
defaultFieldValue={\\"\\"}
Expand Down Expand Up @@ -9614,7 +9614,7 @@ export default function CommentUpdateForm(props) {
: \\"\\"
);
setCurrentPostIDValue(value);
setSelectedPostIDRecords(postIDRecords.find((r) => r.id === value));
setSelectedPostIDRecords([postIDRecords.find((r) => r.id === value)]);
}}
inputFieldRef={postIDRef}
defaultFieldValue={\\"\\"}
Expand Down Expand Up @@ -10344,7 +10344,7 @@ export default function CommentUpdateForm(props) {
: \\"\\"
);
setCurrentPostIDValue(value);
setSelectedPostIDRecords(postIDRecords.find((r) => r.id === value));
setSelectedPostIDRecords([postIDRecords.find((r) => r.id === value)]);
}}
inputFieldRef={postIDRef}
defaultFieldValue={\\"\\"}
Expand Down Expand Up @@ -10997,7 +10997,7 @@ export default function CommentUpdateForm(props) {
: \\"\\"
);
setCurrentPostIDValue(value);
setSelectedPostIDRecords(postIDRecords.find((r) => r.id === value));
setSelectedPostIDRecords([postIDRecords.find((r) => r.id === value)]);
}}
inputFieldRef={postIDRef}
defaultFieldValue={\\"\\"}
Expand Down Expand Up @@ -13869,9 +13869,9 @@ export default function CreateCompositeToyForm(props) {
: \\"\\"
);
setCurrentCompositeDogCompositeToysNameValue(value);
setSelectedCompositeDogCompositeToysNameRecords(
compositeDogCompositeToysNameRecords.find((r) => r.name === value)
);
setSelectedCompositeDogCompositeToysNameRecords([
compositeDogCompositeToysNameRecords.find((r) => r.name === value),
]);
}}
inputFieldRef={compositeDogCompositeToysNameRef}
defaultFieldValue={\\"\\"}
Expand Down Expand Up @@ -13982,11 +13982,11 @@ export default function CreateCompositeToyForm(props) {
: \\"\\"
);
setCurrentCompositeDogCompositeToysDescriptionValue(value);
setSelectedCompositeDogCompositeToysDescriptionRecords(
setSelectedCompositeDogCompositeToysDescriptionRecords([
compositeDogCompositeToysDescriptionRecords.find(
(r) => r.description === value
)
);
),
]);
}}
inputFieldRef={compositeDogCompositeToysDescriptionRef}
defaultFieldValue={\\"\\"}
Expand Down Expand Up @@ -14929,9 +14929,9 @@ export default function CreateCommentForm(props) {
: \\"\\"
);
setCurrentPostCommentsIdValue(value);
setSelectedPostCommentsIdRecords(
postCommentsIdRecords.find((r) => r.id === value)
);
setSelectedPostCommentsIdRecords([
postCommentsIdRecords.find((r) => r.id === value),
]);
}}
inputFieldRef={postCommentsIdRef}
defaultFieldValue={\\"\\"}
Expand Down Expand Up @@ -17788,11 +17788,11 @@ export default function ChildItemUpdateForm(props) {
: \\"\\"
);
setCurrentCustomKeyModelChildrenMycustomkeyValue(value);
setSelectedCustomKeyModelChildrenMycustomkeyRecords(
setSelectedCustomKeyModelChildrenMycustomkeyRecords([
customKeyModelChildrenMycustomkeyRecords.find(
(r) => r.mycustomkey === value
)
);
),
]);
}}
inputFieldRef={customKeyModelChildrenMycustomkeyRef}
defaultFieldValue={\\"\\"}
Expand Down Expand Up @@ -20181,7 +20181,7 @@ export default function CommentUpdateForm(props) {
: \\"\\"
);
setCurrentPostIDValue(value);
setSelectedPostIDRecords(postIDRecords.find((r) => r.id === value));
setSelectedPostIDRecords([postIDRecords.find((r) => r.id === value)]);
}}
inputFieldRef={postIDRef}
defaultFieldValue={\\"\\"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,39 +365,41 @@ export const renderArrayFieldComponent = (
getSetNameIdentifier(`selected${capitalizeFirstLetter(fieldName)}Records`),
undefined,
[
factory.createCallExpression(
factory.createPropertyAccessExpression(
factory.createIdentifier(getRecordsName(fieldName)),
factory.createIdentifier('find'),
),
undefined,
[
factory.createArrowFunction(
undefined,
undefined,
[
factory.createParameterDeclaration(
undefined,
undefined,
undefined,
factory.createIdentifier('r'),
undefined,
undefined,
),
],
undefined,
factory.createToken(SyntaxKind.EqualsGreaterThanToken),
factory.createBinaryExpression(
factory.createPropertyAccessExpression(
factory.createIdentifier('r'),
factory.createIdentifier(scalarKey),
factory.createArrayLiteralExpression([
factory.createCallExpression(
factory.createPropertyAccessExpression(
factory.createIdentifier(getRecordsName(fieldName)),
factory.createIdentifier('find'),
),
undefined,
[
factory.createArrowFunction(
undefined,
undefined,
[
factory.createParameterDeclaration(
undefined,
undefined,
undefined,
factory.createIdentifier('r'),
undefined,
undefined,
),
],
undefined,
factory.createToken(SyntaxKind.EqualsGreaterThanToken),
factory.createBinaryExpression(
factory.createPropertyAccessExpression(
factory.createIdentifier('r'),
factory.createIdentifier(scalarKey),
),
factory.createToken(SyntaxKind.EqualsEqualsEqualsToken),
factory.createIdentifier('value'),
),
factory.createToken(SyntaxKind.EqualsEqualsEqualsToken),
factory.createIdentifier('value'),
),
),
],
),
],
),
]),
],
),
),
Expand Down

0 comments on commit 5c73726

Please sign in to comment.