allow nested widget previews to update

This commit is contained in:
Shawn Erquhart 2017-06-23 13:23:03 -04:00
parent 84ed450ac6
commit 09e631ded7

View File

@ -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() {