【发布时间】:2021-07-22 08:12:20
【问题描述】:
我需要从商店获取用户的 id 到我的操作有没有办法让它正确,因为这是我使用它的方式,但我认为它不正确有没有更好的方法这个。
这是我的行动
export const editNote = (note, userId)=> {
return async dispatch => {
await axios.put(`http://localhost:8080/api/user/${userId}/note`, note
)
.then(response => {
console.log("response from note api", response.body)
})
.catch(e => console.log(e))
}
}
这就是我所说的id
const reducer = useSelector(state => state.user);
const onSubmit = values => {
console.log(values)
dispatch(editNote(values, reducer.id))
}
【问题讨论】:
-
这能回答你的问题吗? stackoverflow.com/a/35674575/11218031
标签: reactjs redux react-redux react-hooks