From 1f04d5224feb8474651d368ce543c5f0b71f9221 Mon Sep 17 00:00:00 2001 From: Vincent Fretin Date: Tue, 16 Jul 2024 13:57:34 +0200 Subject: [PATCH] Fix TextureWidget componentDidUpdate to not crash React UI on aframe 1.6.0 --- src/editor/components/widgets/TextureWidget.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/editor/components/widgets/TextureWidget.js b/src/editor/components/widgets/TextureWidget.js index ac93a464c..65b06812d 100644 --- a/src/editor/components/widgets/TextureWidget.js +++ b/src/editor/components/widgets/TextureWidget.js @@ -88,17 +88,11 @@ export default class TextureWidget extends React.Component { this.setValue(this.props.value || ''); } - componentDidUpdate() { - var component = this.props.entity.components[this.props.componentname]; - if (!component) { - return; - } - // component.attrValue may be undefined if component is from a mixin - var newValue = component.attrValue && component.attrValue[this.props.name]; - - // This will be triggered typically when the element is changed directly with element.setAttribute - if (newValue && newValue !== this.state.value) { - this.setValue(newValue); + componentDidUpdate(prevProps) { + // This will be triggered typically when the element is changed directly with + // element.setAttribute. + if (!Object.is(this.props.value, prevProps.value)) { + this.setValue(this.props.value); } }