Login.jsx component

mail@pastecode.io avatar
unknown
javascript
19 days ago
338 B
3
Indexable
Never
//dispatches the login POST request
  const handleSubmit = (e) => {
    e.preventDefault()
    login(loginFormData)
  }
  // sets authentication to state
  // navigates to home
  useEffect(() => {
    if (isSuccess && data) {
      dispatch(setCredentials(data.token))
      navigate("/")
    }
  }, [isSuccess, data, navigate, dispatch])
Leave a Comment