Skip to content

Commit

Permalink
Prevent app from crashing when answerExpression is null in useCodingC…
Browse files Browse the repository at this point in the history
…alculatedExpression
  • Loading branch information
fongsean committed Aug 12, 2024
1 parent 4206090 commit 4ffcfc0
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function useCodingCalculatedExpression(
);

let newCodings: Coding[] = [];
if (Array.isArray(answerExpression.options)) {
if (answerExpression && Array.isArray(answerExpression.options)) {
newCodings = answerExpression.options as Coding[];
}

Expand Down Expand Up @@ -87,7 +87,7 @@ function useCodingCalculatedExpression(
},
// Only trigger this effect if calculatedExpression of item changes
// eslint-disable-next-line react-hooks/exhaustive-deps
[calculatedExpressions, answerExpression.version]
[calculatedExpressions, answerExpression?.version]
);

return { calcExpUpdated: calcExpUpdated };
Expand Down

0 comments on commit 4ffcfc0

Please sign in to comment.