connected-react-router#replace TypeScript Examples
The following examples show how to use
connected-react-router#replace.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ErrorPage.tsx From msteams-meetings-template with MIT License | 6 votes |
mapDispatchToProps = (dispatch: Dispatch) => ({
goBack: () => dispatch(goBack()),
retryCreateMeeting: (meeting: OnlineMeetingInput) => {
dispatch(replace('/createMeeting'));
dispatch({
type: CREATE_MEETING_COMMAND,
meeting
} as CreateMeetingCommand);
}
})
Example #2
Source File: middleware.ts From msteams-meetings-template with MIT License | 5 votes |
export function createAuthMiddleware(): Middleware {
return store => next => action => {
if (action.type === CHECK_FOR_SIGNEDIN_USER_COMMAND) {
if (!msalApp.getAccount()) {
store.dispatch(replace('/signin'));
}
}
if (action.type === OPEN_SIGNIN_DIALOG_COMMAND) {
msalApp
.loginPopup({
scopes: ['OnlineMeetings.ReadWrite']
})
.then(response => {
console.log('Login succeeded');
store.dispatch({
type: SIGNIN_COMPLETE_EVENT,
idToken: response.idToken
} as SigninCompleteEvent);
})
.catch(error => {
console.log('Login failed:', error);
});
}
if (action.type === SIGNIN_COMPLETE_EVENT) {
store.dispatch(replace('/'));
}
if (action.type === SIGNOUT_COMMAND) {
msalApp.logout();
store.dispatch({
type: SIGNOUT_COMPLETE_EVENT
});
console.log('logged out?');
}
next(action);
};
}