useCurrentStateAndParams don't reacting on initial state
On refresh browser page, this hook return empty state, instead of my correct state: {"name":"","url":"^","views":null,"params":{"#":{"value":null,"type":"hash","dynamic":true}},"abstract":true}.
But router.transitionService.onSuccess called with my correct state.
export const useCurrentStateAndParams = () => {
const globals = useRouter().globals;
const [ stateData, setStateData ] = useState({ state: globals.current, params: globals.params });
router.transitionService.onSuccess({}, (transition) => {
// Reacting with my correct state
console.log('onSuccess');
setStateData({ state: transition.to(), params: transition.params('to') });
});
useOnStateChanged((state, params) => {
// Reacting with empty state
console.log('useOnStateChanged');
setStateData({ state, params });
});
return stateData;
};
I am picking up this
Is anyone here
Is anyone here
Better use react-router
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
This does not mean that the issue is invalid. Valid issues may be reopened.
Thank you for your contributions!
This issue has been automatically closed.