From 9351c4b8fb24d91665465e7a434b9c17a21ef699 Mon Sep 17 00:00:00 2001 From: Ajay Sabhaney Date: Tue, 17 Jan 2017 02:53:51 -0700 Subject: [PATCH] View fix --- src/components/view/index.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/view/index.js b/src/components/view/index.js index 107759b..ecbff2c 100644 --- a/src/components/view/index.js +++ b/src/components/view/index.js @@ -83,11 +83,16 @@ export default class View extends Component { } }) - if (Object.keys(stateModifier).length > 0) { - this.setState(stateModifier, () => { - this.updateComponentSizeAndPosition() - }) - } + // Even if nothing has changed, we force a re-render since + // this may have been triggered by a state change in the parent + // component. And since the parent component's state has an + // impact on width and aspect ratio, it could therefore change + // this component's width and aspect ratio as well. + // TODO: Check if an ancestor view has changed in a relevant way + // in order to not render unecessarily. + this.setState(stateModifier, () => { + this.updateComponentSizeAndPosition() + }) } componentWillUnmount() {