import React, { useState, useContext } from 'react'; import { useHistory } from 'react-router-dom'; import { FirebaseContext } from '../context/firebase'; import { HeaderContainer } from '../containers/header'; import { FooterContainer } from '../containers/footer'; import { Form } from '../components'; import * as ROUTES from '../constants/routes'; export default function Signin() { const history = useHistory(); const { firebase } = useContext(FirebaseContext); const [emailAddress, setEmailAddress] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const isInvalid = password === '' || emailAddress === ''; const handleSignIn = (event) => { event.preventDefault(); // firebase work here! firebase.auth() .signInWithEmailAndPassword(emailAddress, password) .then(() => { //push to the browse page history.push(ROUTES.BROWSE); }) .catch((error) => { setEmailAddress(''); setPassword(''); setError(error.message); }); }; return ( <>
Sign In {error && {error}} setEmailAddress(target.value)} /> setPassword(target.value)} /> SignIn New to Netflix? Sign up now. This page is protected by Google reCAPCTHA to ensure that you are not a bot. Learn more.
; ); }