diff --git a/.changeset/mean-fans-boil.md b/.changeset/mean-fans-boil.md new file mode 100644 index 0000000000..75fae553b0 --- /dev/null +++ b/.changeset/mean-fans-boil.md @@ -0,0 +1,5 @@ +--- +"@khanacademy/perseus": patch +--- + +Minor refactoring of ServerItemRenderer's componentDidUpdate to reduce duplication diff --git a/packages/perseus/src/server-item-renderer.tsx b/packages/perseus/src/server-item-renderer.tsx index f842ad5e13..8e5dff99b5 100644 --- a/packages/perseus/src/server-item-renderer.tsx +++ b/packages/perseus/src/server-item-renderer.tsx @@ -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) {