score:0

you can not do this in easy ways. the best thing to do to fix this is to add condition on the data you get from the server that if data is empty, after you can use condional rendering and set if data is null you return some jsx that show this page has no data ;

// if user select /user/23
    {data?<div>empty ! </div>}

but if you select route like /usersdadsa and didnt catch any error or didnt redirect to notfound page you have to set react router in this approach //if user select /udasuasdusad

                <route path='*' component={notfound} />

and put it in the end of your routes , when user select your route , react router try to match the user route with your routes and if any route doesnt match so they found your last route that tell react router to all path should render notfound component


Related Query

More Query from same tag