After successfull API invocation, I am calling window.onload
for component refresh to redirect to the specific route.
export function _getUserPlanForUser(data) {
let token = localStorage.getItem('accessToken');
let url = "/userplans/listuserplans?access_token=" + token;
let BASE = "http://172.104.176.144:9080"
let actualurl = BASE + url;
Api._callAPI(actualurl, 'GET', data, (type, dt) => {
if (type == 'success') {
dispatcher.dispatch({
type: 'UsersPlansForUser',
data: dt,
})
window.onload = function() {
if(!window.location.hash) {
window.location = window.location + '#loaded';
window.location.reload(true);
}
}
}
});
}
And in the routes.js
file I am validating based on condition
import React from 'react';
import { Route, IndexRoute } from 'react-router';
import App from './components/App';
import loginPage from './components/login/login.component.jsx';
import dashboard from './components/dashboard';
import Home from './components/Home/home.jsx';
import Myplan from './components/MyPlan/myplan.jsx';
export default (
<Route component={App}>
<Route path="/" >
<IndexRoute component={loginPage} />
</Route>
<Route path="/dashboard" component={dashboard} >
{
(localStorage.getItem("ValidateRoute")) == "0" ?
[
<IndexRoute component={Myplan} />,
<Route path='/home' component={Home} />
] : [
<IndexRoute component={Home} />,
<Route path='/myplan' component={Myplan} />
]
}
</Route>
</Route>
);
Based on condition ValidateRoute
I am routing to specific component after a successfull reload!
Everything working fine on Chrome, but as window.reload
is not working it is not redirecting to the specific route!
Please give me some guidelines for reload on Mozilla (or) proper redirection in Mozilla to the particular route.
I've been working for 1 week and still cannot find any soulution. Issue fixed would be very helpfull to me.