The correct answer is valid but it will not cover all the scenarios, if you need to detect the edit mode from an SPFx solution on a classic page the Mode=Edit will not be available.
A more reliable solution would be to use the DisplayMode
//Detect display mode on classic and modern pages pages
if(Environment.type == EnvironmentType.ClassicSharePoint){
let isInEditMode: boolean;
let interval: any;
interval = setInterval(function(){
if (typeof (<any>window).SP.Ribbon !== 'undefined'){
isInEditMode = (<any>window).SP.Ribbon.PageState.Handlers.isInEditMode();
if(isInEditMode){
//Classic SharePoint in Edit Mode
}else{
//Classic SharePoint in Read Mode
}
clearInterval(interval);
}
},100)
}else if(Environment.type == EnvironmentType.SharePoint){
if(this.displayMode == DisplayMode.Edit){
//Modern SharePoint in Edit Mode
}else if(this.displayMode == DisplayMode.Read){
//Modern SharePoint in Read Mode
}
}
More information about this can be fount here
DisplayMode
in SPFx?