我有一个动作POST向服务器发出请求以更新用户的密码,但我无法处理链接的catch块中的错误.
return axios({
method: 'post',
data: {
password: currentPassword,
new_password: newPassword
},
url: `path/to/endpoint`
})
.then(response => {
dispatch(PasswordUpdateSuccess(response))
})
.catch(error => {
console.log('ERROR', error)
switch (error.type) {
case 'password_invalid':
dispatch(PasswordUpdateFailure('Incorrect current password'))
break
case 'invalid_attributes':
dispatch(PasswordUpdateFailure('Fields must not be blank'))
break
}
})
Run Code Online (Sandbox Code Playgroud)
当我记录错误时,这就是我所看到的:
当我检查网络选项卡时,我可以看到响应正文,但由于某种原因我无法访问这些值!
我在某个地方不知不觉地犯了错误吗?因为我正在处理来自不同请求的其他错误,但似乎无法正常工作.
我创建了一个Section组件,它将图像作为属性,其子项作为内容显示在该部分中,因此该组件看起来如下...
<Section image={'path/to/image'}>
//content
</Section>
Run Code Online (Sandbox Code Playgroud)
该组件将获取image属性并将其设置为背景图像样式的URL ...
let sectionStyle = {
backgroundImage: `url(${this.props.image})`
}
Run Code Online (Sandbox Code Playgroud)
然后将在返回元素中处理...
return (
<section
style={this.props.image ? sectionStyle : null}>
<div>
{this.props.children}
</div>
</section>
)
Run Code Online (Sandbox Code Playgroud)
我的问题是,是否有可能延迟加载背景图像,同时也不会影响SEO的内容可用性?换句话说,我想避免LazyLoading整个Section,但不知何故,LazyLoad只是与Section相关联的图像.
我知道如何使用本地删除分支
git branch -d <branch_name>
以及如何使用本地和远程删除
git push origin --delete <branch_name>
我最近也学习了如何修剪过时的分支,只有这样做时,我才能在运行此命令时看到远程分支列表中反映的更改
git branch -r
但每当我运行此命令时,分支列表似乎仍然显示所有分支
git branch
是否有一个命令可以同步远程的更改以反映在本地分支列表中,这样当我删除 github 上的分支时,我可以提取所有分支更改的更新,即哪些分支已被删除,哪些仍然保留,进入我的本地环境?
用例:
用户订阅后,我想导航到另一个页面,通知用户验证他们的电子邮件。
try {
const request = yield call(subcribe, action.payload.data)
yield put({ type: SUBSCRIBE_SUCCESS, payload: request.data })
yield put(showNotification(NOTIFICATION_SUCCESS, 'Please check your email.'))
} catch(e) {
...
}
Run Code Online (Sandbox Code Playgroud)
有没有办法导航到成功页面,即/subscribe-success一旦我收到服务器的成功响应?
reactjs ×3
javascript ×2
axios ×1
css ×1
git ×1
github ×1
html ×1
lazy-loading ×1
react-router ×1
redux ×1
redux-saga ×1