Commit 744660e7 authored by seoyeon's avatar seoyeon
Browse files

useRef

parent 529e50de
import { useEffect, useState } from 'react' import { useEffect, useState, useRef } from 'react'
import { Redirect } from 'react-router-dom' import { Redirect } from 'react-router-dom'
import userApi from '../apis/user.api' import userApi from '../apis/user.api'
import catchErrors from "../context/catchError"; import catchErrors from '../context/catchError'
import { handleLogin } from '../context/auth'; import { handleLogin } from '../context/auth'
const INIT_USER = { const INIT_USER = {
email: '', email: '',
password: '', password: '',
} }
const Login = () => { const Login = () => {
// const { loading, login, catchErrorAuth } = useAuth()
const [user, setUser] = useState(INIT_USER) const [user, setUser] = useState(INIT_USER)
const [disabled, setDisabled] = useState(true) const [disabled, setDisabled] = useState(true)
const [error, setError] = useState('') const [error, setError] = useState('')
const [success, setSuccess] = useState(false) const [success, setSuccess] = useState(false)
// const [modalopen, setmodalOpen] = useState(false)
// const loginref = useRef()
useEffect(() => { useEffect(() => {
const isUser = Object.values(user).every((el) => Boolean(el)) const isUser = Object.values(user).every((el) => Boolean(el))
isUser ? setDisabled(false) : setDisabled(true) isUser ? setDisabled(false) : setDisabled(true)
// window.addEventListener('click', handleModal)
// return () => {
// window.removeEventListener('click', handleModal)
// }
}, [user]) }, [user])
function handleChange(event) { function handleChange(event) {
...@@ -25,6 +30,14 @@ const Login = () => { ...@@ -25,6 +30,14 @@ const Login = () => {
setUser({ ...user, [name]: value }) setUser({ ...user, [name]: value })
} }
// const handleModal = (e) => {
// if (
// modalopen &&
// (!loginref.current || !loginref.current.contains(e.target))
// )
// setmodalOpen(false)
// }
async function handleSubmit(e) { async function handleSubmit(e) {
e.preventDefault() e.preventDefault()
console.log('로그인') console.log('로그인')
...@@ -51,7 +64,6 @@ const Login = () => { ...@@ -51,7 +64,6 @@ const Login = () => {
return ( return (
<div className="modal-content"> <div className="modal-content">
{error && <div className="alert alert-danger">{error}</div>}
<form onSubmit={handleSubmit}> <form onSubmit={handleSubmit}>
<div className="modal-header"> <div className="modal-header">
<h5 className="modal-title" id="loginModalLabel"> <h5 className="modal-title" id="loginModalLabel">
...@@ -64,6 +76,7 @@ const Login = () => { ...@@ -64,6 +76,7 @@ const Login = () => {
aria-label="Close" aria-label="Close"
></button> ></button>
</div> </div>
{error && <div className="alert alert-danger">{error}</div>}
<div className="modal-body"> <div className="modal-body">
<div> <div>
<label>아이디</label> <label>아이디</label>
......
...@@ -2,9 +2,9 @@ import ScreenSelect from './ScreenSelect' ...@@ -2,9 +2,9 @@ import ScreenSelect from './ScreenSelect'
import React, { useState } from 'react'; import React, { useState } from 'react';
const Controller = () => { const Controller = () => {
const [mic, setMic] = useState("true") const [mic, setMic] = useState(true)
const [speaker, setSpeaker] = useState("true") const [speaker, setSpeaker] = useState(true)
const [video, setVideo] = useState("true") const [video, setVideo] = useState(true)
const micOn = (() => setMic(false)); const micOn = (() => setMic(false));
const micOff = (() => setMic(true)); const micOff = (() => setMic(true));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment