You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LogIn.jsx 1005B

123456789101112131415161718192021222324252627282930313233
  1. import React from "react";
  2. import { useState } from "react";
  3. import { View, TextInput } from "react-native";
  4. import Button from "../components/Buttons/Button";
  5. import { login } from "../thunks/user.thunk";
  6. export const LogIn = () => {
  7. const [username, setUsername] = useState()
  8. const [password, setPassword] = useState()
  9. const [error, setError] = useState()
  10. return (
  11. <View>
  12. <TextInput focus={true}
  13. style={{ marginTop: 20 }}
  14. placeholder='Username' />
  15. <TextInput focus={true}
  16. style={{ marginTop: 20 }}
  17. placeholder='Password'
  18. secureTextEntry />
  19. <Button onPress={() => dispatch(
  20. login(username, password, function (result) {
  21. if (!result.OK) {
  22. setUsername("");
  23. setPassword("");
  24. setError(result.data.Message ? result.data.Message : "Error occurred during Login,please try again!");
  25. }
  26. })
  27. )} title='Log In' style={{ backgroundColor: 'red' }} />
  28. </View>
  29. )
  30. }