How to call navigate inside Redux Toolkit's actions in React js
I've a simple app built on redux-toolkit. I am dispatching createProduct actions which is working fine. I want to navigate to /products/ page form /products/new page after createProduct action. How...
stackoverflow.com
페이지 안에서 response 값을 unwrap()으로 부를수 있다
const Loginin = async () => {
try {
const response = await dispatch(adminLogin(loginInput)).unwrap();
console.log(response);
if (response.ok === true) {
navigate("/admin");
window.localStorage.setItem("adminUserId", loginInput.adminId);
} else {
alert("잘못된 아이디 비번");
}
} catch (error) {
console.log(error);
}
};
'A.개발관련자료' 카테고리의 다른 글
[0]nestjs 페이징 ( take, skip 사용) (0) | 2022.07.18 |
---|---|
[0]increment decrement button (0) | 2022.06.28 |
[0]react 스크롤시 해당 위치(id)로 이동하기 : <a href = "#tagname"> ,scrollEvent (0) | 2022.06.21 |
[0]클릭시 하단으로 이동 (0) | 2022.05.27 |
[0]특정파일의 크기가 너무 커서 submit시 전송이 안되는 경우 : file의 사이즈에 문제가 있을 경우 (0) | 2022.05.26 |