From e3e3315125b466b26b45eede148e8f6e6e22ee45 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sat, 9 Oct 2021 10:10:51 +0200 Subject: [PATCH] Inherit from default connectParams in handleConfig When handleConfig is called, this.state.connectParams will be set to its default value. Inherit from it so that autoconnect isn't missing any. If we ever add a new connect parameter, we don't want an old localStorage to break connect() because it's missing the param. --- components/app.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/components/app.js b/components/app.js index 41a57d5..6688559 100644 --- a/components/app.js +++ b/components/app.js @@ -184,12 +184,13 @@ export default class App extends Component { * - URL params * - Saved parameters in local storage * - Configuration data (fetched from the config.json file) - * - Default server URL constructed from the current URL location + * - Default server URL constructed from the current URL location (this is + * done in fillConnectParams) */ handleConfig(config) { this.setState({ loading: false }); - let connectParams = {}; + let connectParams = { ...this.state.connectParams }; if (config.server) { if (typeof config.server.url === "string") { @@ -233,14 +234,7 @@ export default class App extends Component { this.config = config; - this.setState((state) => { - return { - connectParams: { - ...state.connectParams, - ...connectParams, - }, - }; - }); + this.setState({ connectParams: connectParams }); if (connectParams.autoconnect) { this.setState({ connectForm: false });