本文整理汇总了TypeScript中react-router.browserHistory.push方法的典型用法代码示例。如果您正苦于以下问题:TypeScript browserHistory.push方法的具体用法?TypeScript browserHistory.push怎么用?TypeScript browserHistory.push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类react-router.browserHistory
的用法示例。
在下文中一共展示了browserHistory.push方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: VerifiedAccount
function* VerifiedAccount(action: any): SagaIterator {
const toastId = toast.info('Verifying account...', {
className: 'toast',
})
try {
const { token, password } = action.payload
yield put(Actions.LoadingPage.onLoadingOn())
const data = yield call(GetApiTokensFrost, token, password)
yield put(Actions.VerifiedAccount.onVerifiedAccountSuccess())
yield put(Actions.LoadingPage.onLoadingFull())
yield put(Actions.SignOut.onSignOut({ redirectLogin: false }))
yield put(Actions.SetTokenLogin.onSetTokenLogin(data))
yield call(delay, 1000)
browserHistory.push('/dashboard')
toast.success('Your account has been verified!', {
className: 'toast',
autoClose: 2500,
})
} catch (e) {
yield put(Actions.LoadingPage.onLoadingFull())
yield put(Actions.VerifiedAccount.onVerifiedAccountError(e))
yield call(delay, 300)
yield put(Actions.VerifiedAccount.onVerifiedAccountClearError())
if (e.includes('Email already verified')) {
browserHistory.push('/dashboard')
toast.info(e, {
className: 'toast',
autoClose: 2500,
})
} else if (e.includes('Expired token')) {
const message = 'This link has expired. Please login and request a new validation email.'
toast.update(toastId, {
render: message,
type: toast.TYPE.ERROR,
className: 'toast',
autoClose: false,
})
} else
toast.update(toastId, {
render: e,
type: toast.TYPE.ERROR,
autoClose: false,
className: 'toast',
})
}
}
示例2: failCB
function failCB(ex:any):void {
toast("error", "some error", "error");
console.log(ex);
if(ex.status === 401){
browserHistory.push('/login?failed=true');
}
}
示例3: SignOut
function SignOut(action: any): void {
try {
if (!(action.payload && action.payload.redirectLogin === false)) browserHistory.push('/login')
} catch (e) {
// Todo: Error message in UI
}
}
示例4: ChangePasswordToken
function* ChangePasswordToken(action: any): SagaIterator {
try {
const { token, password } = action.payload
yield put(Actions.LoadingPage.onLoadingOn())
const data = yield call(ChangePasswordTokenFrost, token, password)
yield put(Actions.ChangePasswordToken.onChangePasswordTokenSuccess(data))
yield put(Actions.LoadingPage.onLoadingFull())
yield put(Actions.SignOut.onSignOut({ redirectLogin: false }))
yield put(Actions.SetTokenLogin.onSetTokenLogin(data))
yield call(delay, 1000)
browserHistory.push('/dashboard')
toast.success('Your password has been updated!', {
className: 'toast',
autoClose: 2500,
})
} catch (e) {
yield put(Actions.LoadingPage.onLoadingFull())
yield put(Actions.ChangePasswordToken.onChangePasswordTokenError(e))
yield call(delay, 300)
yield put(Actions.ChangePasswordToken.onChangePasswordTokenClearError())
toast.error(e, {
className: 'toast',
autoClose: 2500,
})
}
}
示例5: Chance
const newNode = () => {
const chance = new Chance();
const id = chance.guid();
browserHistory.push(`/${id}`)
return {
type: action.NEW_NODE,
payload: { keys: [id], values: {[id]: {id, name: '', recipe: ''}}}
}
};
示例6: searchOffsetChange
function* searchOffsetChange(action: WorkSearchAction): any {
browserHistory.push({
pathname: 'works',
query: {
...browserHistory.getCurrentLocation().query,
offset: action.offset,
},
})
}
示例7: dispatch
request.then(response => {
try {
browserHistory.push('/');
dispatch(flushSearch());
dispatch(fetchData());
} catch (e) {
throw e
} finally {
dispatch(resRecieved());
}
}).catch(e => {
示例8: HandleEvent
public static HandleEvent(roomID : string) {
Hub.socket.inRoom = true;
browserHistory.push(`/${roomID}`);
Hub.logger.logSuccess(`> Joined room: ${roomID}`);
if(Hub.youtube.IsPlayerReady())
{
Hub.socket.getYoutubePlayerState();
}
else
{
Hub.dispatcher.addEventListener("youtube_player_ready", JoinRoomSuccessEvent.OnYoutubePlayerLoaded);
}
}
示例9: navigateTo
export function navigateTo(path, event?) {{{
if (last_navigateTo.path === path && Date.now() - last_navigateTo.timestamp < 100) {
/* debounce, this is for elements that need to have both onClick and onMouseUp to
* handle various use cases in different browsers */
console.log('navigate debounce');
return false;
}
last_navigateTo.path = path;
last_navigateTo.timestamp = Date.now();
if (event && shouldOpenNewTab(event)) {
window.open(path, "_blank");
} else {
browserHistory.push(path);
}
}}}
示例10: SignUp
function* SignUp(action: any): SagaIterator {
try {
const { email, password } = action.payload
yield put(Actions.LoadingPage.onLoadingOn())
const { token } = yield call(signUpFrost, { email, password })
yield put(Actions.SignUp.onSignUpSuccess({ token, ...{ profile: { email } } }))
yield put(Actions.Profile.onProfile({ token }))
yield put(Actions.LoadingPage.onLoadingFull())
yield call(delay, 300)
browserHistory.push('/dashboard')
} catch (e) {
yield put(Actions.LoadingPage.onLoadingFull())
yield put(Actions.SignUp.onSignUpError(e))
yield call(delay, 300)
yield put(Actions.SignUp.onSignUpClearError())
}
}