set selectedDevice to null instead of undefined
Summary: We are using `redux-persist` to persist parts of our redux store over reloads. In this library, there is a check if a value "was removed to the store". However, they are doing this check by checking if the value of this key is `undefined`. This is not a good way of checking if a property exists on an object, because it can exists but explicitly be set to `undefined`. This was the case for `connections.selectedDevice`, we were setting the value to undefined, once the device disconnected. This caused the key to be persisted, eventhough it wasn't whitelisted for persisting. In this diff, we are setting the `selectedDevice` to `null` instead of `undefined` once a device disconnects. Reviewed By: passy Differential Revision: D16121260 fbshipit-source-id: f32c8ea9e30f02e065fa63380ae0245379a47496
This commit is contained in:
committed by
Facebook Github Bot
parent
660fa71505
commit
5c96b0952b
@@ -189,7 +189,7 @@ const reducer = (state: State = INITAL_STATE, action: Action): State => {
|
||||
let selection = {};
|
||||
if (selectedDeviceWasRemoved) {
|
||||
selection = {
|
||||
selectedDevice: devices[devices.length - 1],
|
||||
selectedDevice: devices[devices.length - 1] || null,
|
||||
selectedApp: null,
|
||||
selectedPlugin: DEFAULT_PLUGIN,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user