Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 7c28bca

Browse files
committed
fix(plugins/plugin-client-common): improved fix for CodeBlock setState after unmount
1 parent c442a31 commit 7c28bca

File tree

1 file changed

+7
-6
lines changed
  • plugins/plugin-client-common/src/components/Views/Terminal/Block

1 file changed

+7
-6
lines changed

plugins/plugin-client-common/src/components/Views/Terminal/Block/Inputv2.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,20 +179,21 @@ export default class CodeBlock<T1, T2, T3> extends StreamingConsumer<Props<T1, T
179179
private doValidate() {
180180
if (this.props.blockId && this.props.validate) {
181181
setTimeout(async () => {
182-
if (!this.mounted) {
183-
return
184-
}
185-
186182
try {
187183
// .toString() in case of e.g. `validate: true` which yaml
188184
// parsers pass to us as a boolean
189185
this.emitLinkStatus('processing')
190186
await pexecInCurrentTab(this.props.validate.toString(), undefined, true, true)
191187
this.emitLinkStatus('done')
192-
this.setState({ validated: true })
188+
189+
if (this.mounted) {
190+
this.setState({ validated: true })
191+
}
193192
} catch (err) {
194193
this.emitLinkStatus('not-yet')
195-
this.setState({ validated: false })
194+
if (this.mounted) {
195+
this.setState({ validated: false })
196+
}
196197
}
197198
}, 1000)
198199
}

0 commit comments

Comments
 (0)