How does react-router4 jump according to the judgment condition?

The

logic is like this: the project default route is home component , determine whether there is address in localStorage , if not, jump to address component to select an address, and then jump to home component . In vue, I judge in created and then use push to jump. React-rouer documents have read but still do not know how to do

.
Mar.30,2021

interface IDemo extends RouteComponentProps<{}>{}

class Demo extends React.Component<IDemo,{}>{
    
    componentDidMount(){
        if(!localStorage.get('XX)){
            this.props.location.history.push('/)
        }
      
    }

}
export default withRouter(Demo)

it's basically the same process to put

Menu