From 04d2880b25180ff4a140f2000702b8cb978010b8 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Wed, 6 Mar 2019 09:27:32 -0800 Subject: [PATCH] Bug fix when the selectedPlugin is Layout, and trace is imported Summary: Fixes a bug which happened when the selected plugin was layout and the flipper trace was imported. While importing the trace in the mentioned scenario, the redux store didn't used to get updated in the first render but got updated in the second render. Due to which the persisted state passed in the props was undefined. Look at the attached video to understand the bug. BUG: {F152642401} Reviewed By: passy Differential Revision: D14343465 fbshipit-source-id: 59110fd6ee5839f2e3944792e1c288d2388d3340 --- src/plugins/layout/layout2/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/layout/layout2/index.js b/src/plugins/layout/layout2/index.js index f91c11e0e..29f50e8ba 100644 --- a/src/plugins/layout/layout2/index.js +++ b/src/plugins/layout/layout2/index.js @@ -85,6 +85,10 @@ export default class Layout extends FlipperPlugin { }; init() { + if (!this.props.persistedState) { + // If the selected plugin from the previous session was layout, then while importing the flipper trace, the redux store doesn't get updated in the first render, due to which the plugin crashes, as it has no persisted state + this.props.setPersistedState(this.constructor.defaultPersistedState); + } // persist searchActive state when moving between plugins to prevent multiple // TouchOverlayViews since we can't edit the view heirarchy in onDisconnect this.client.call('isSearchActive').then(({isSearchActive}) => {