From 09e631ded707db1038f69c6d9cfa202a6d554889 Mon Sep 17 00:00:00 2001 From: Shawn Erquhart Date: Fri, 23 Jun 2017 13:23:03 -0400 Subject: [PATCH] allow nested widget previews to update --- src/components/Widgets/PreviewHOC.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/Widgets/PreviewHOC.js b/src/components/Widgets/PreviewHOC.js index dc25977a..1ecaa529 100644 --- a/src/components/Widgets/PreviewHOC.js +++ b/src/components/Widgets/PreviewHOC.js @@ -2,7 +2,11 @@ import React from 'react'; class PreviewHOC extends React.Component { shouldComponentUpdate(nextProps) { - return nextProps.value !== this.props.value; + // Only re-render on value change, but always re-render objects and lists. + // Their child widgets will each also be wrapped with this component, and + // will only be updated on value change. + const isWidgetContainer = ['object', 'list'].includes(nextProps.field.get('widget')); + return isWidgetContainer || this.props.value !== nextProps.value; } render() {