本文整理汇总了TypeScript中react-toastify.toast.success方法的典型用法代码示例。如果您正苦于以下问题:TypeScript toast.success方法的具体用法?TypeScript toast.success怎么用?TypeScript toast.success使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类react-toastify.toast
的用法示例。
在下文中一共展示了toast.success方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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,
})
}
}
示例2: if
.then(response => {
if (action.meta && action.meta.successMessage) {
toast.success(action.meta.successMessage);
} else if (response && response.action && response.action.payload && response.action.payload.headers) {
const headers = response.action.payload.headers;
let alert: string = null;
let alertParams: string = null;
Object.entries(headers).forEach(([k, v]: [string, string]) => {
if (k.endsWith('app-alert')) {
alert = v;
} else if (k.endsWith('app-params')) {
alertParams = v;
}
});
if (alert) {
const alertParam = alertParams;
toast.success(translate(alert, { param: alertParam }));
}
}
return Promise.resolve(response);
})
示例3: 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',
})
}
}