TagSpaces is an offline, open source, document manager with tagging support
fix showing location initially by existing default location
Ilian Sapundshiev717b6705eb1b
diff --git a/app/components/LocationMenu.js b/app/components/LocationMenu.jsindex 9a14780c0..842c45987 100644--- a/app/components/LocationMenu.js+++ b/app/components/LocationMenu.js@@ -56,23 +56,20 @@ class LocationMenu extends React.Component { // <Props, State>locationChooserMenuAnchorEl: null,}- componentWillReceiveProps = (nextProps: Props) => {- if (nextProps.currentLocationId != null) {- this.props.locations.map((location: Location) => {+ static getDerivedStateFromProps(nextProps, prevState) {+ let currentLocation;+ if (nextProps.currentLocationId && nextProps.locations) {+ nextProps.locations.map((location: Location) => {if (location.uuid === nextProps.currentLocationId) {- this.setState({- currentLocation: location,- });+ currentLocation = location;}- return true;- });- } else {- // closing the perspective- this.setState({- currentLocation: undefined,});}- };+ return {+ ...prevState,+ currentLocation,+ };+ }openLocation = location => {this.props.openLocation(location);