Skip to content

Commit

Permalink
SSS: Remove duplicate nullness check on answerableCallback (#1947)
Browse files Browse the repository at this point in the history
## Summary:

A super small refactoring of the `componentDidUpdate` to reduce some duplication.

Issue: LEMS-2561

## Test plan:

`yarn test`
`yarn typecheck`

Author: jeremywiebe

Reviewers: handeyeco, Myranae

Required Reviewers:

Approved By: handeyeco

Checks: ✅ gerald, ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald

Pull Request URL: #1947
  • Loading branch information
jeremywiebe authored Dec 4, 2024
1 parent 6e186ac commit b8926e3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/mean-fans-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

Minor refactoring of ServerItemRenderer's componentDidUpdate to reduce duplication
8 changes: 3 additions & 5 deletions packages/perseus/src/server-item-renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,11 @@ export class ServerItemRenderer
}

componentDidUpdate(prevProps: Props, prevState: State) {
if (this.props.apiOptions.answerableCallback) {
const answerableCallback = this.props.apiOptions.answerableCallback;
if (answerableCallback != null) {
const isAnswerable =
this.questionRenderer.emptyWidgets().length === 0;
const {answerableCallback} = this.props.apiOptions;
if (answerableCallback) {
answerableCallback(isAnswerable);
}
answerableCallback(isAnswerable);
}

if (!this._fullyRendered) {
Expand Down

0 comments on commit b8926e3

Please sign in to comment.