From 69c5776c3af3a7372fbe32660945533ad60b1a82 Mon Sep 17 00:00:00 2001 From: Vincent Fretin Date: Sun, 16 Jun 2024 11:21:21 +0200 Subject: [PATCH] Fix TextureWidget componentDidUpdate to not crash React UI on aframe 1.6.0 (fix #722) --- src/components/widgets/TextureWidget.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/components/widgets/TextureWidget.js b/src/components/widgets/TextureWidget.js index 00b48493..632c4746 100644 --- a/src/components/widgets/TextureWidget.js +++ b/src/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); } }