I am a newbie to react have implemented a redirect logic depending on what response I am getting back from an API. Now based on the API response I am seeing that the URL is changing on the browser but nothing is getting displayed. When I refresh the link in the browser tab then the page is getting loaded.Looked at similar issues in stackoverflow but nothing seems to work in my situation. Any help/ guidance in this regard will be helpful. Thanks in advance
import ReactDOM from 'react-dom';
import {
Route,
Switch,
HashRouter,
withRouter,
Redirect
} from 'react-router-dom';
<HashRouter>
<Switch>
<Route exact path="/" component={withRouter (RoutePage)}>
{UserStatus === 'Migrated' && audience === 'admin'
? <Redirect to="/adminConfirmation" />
: null
}
{UserStatus === 'Repeated' && audience === 'admin'
? <Redirect to="/admin-hub" />
: null
}
{UserStatus === 'Migrated' && audience === 'user'
? <Redirect to="/userConfirmation" />
: null
}
{UserStatus === 'Repeated' && audience === 'user'
? <Redirect to="/user-hub" />
: null
}
</Route>
<Route exact path="/admin-hub" component={withRouter (Admin)} />
<Route exact path="/user-hub" component={withRouter (UserHub)} />
<Route
exact
path="/adminConfirmation"
component={withRouter(AdminConfirmation)}
/>
<Route
exact
path="/userConfirmation"
component={withRouter(UserConfirmation)}
/>
</Switch>
</HashRouter>