import React from "react"; import { useState } from "react"; import { View, TextInput, Text, StyleSheet } from "react-native"; import Button from "../components/Buttons/Button"; import { login } from "../thunks/user.thunk"; import { useDispatch } from "react-redux"; export const LogIn = () => { const [username, setUsername] = useState() const [password, setPassword] = useState() const [error, setError] = useState() const dispatch = useDispatch(); const loginHandler = () => { dispatch( login(username, password, function (result) { console.log(result.data) if (!result.OK) { setUsername(""); setPassword(""); setError(result.data.Message ? result.data.Message : "Error occurred during Login,please try again!"); } }) ) } return ( {error && error}