Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions src/features/group/InviteInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
personal
}: Props) {
const [userList, setUserList] = useState<Users[]>([])
const inputRef = useRef<HTMLInputElement>(null)
const [inputValue, setInputValue] = useState<string>('')
const [drop, setDrop] = useState(false)
const [loading, setLoading] = useState(false)
const [convertState, setConvertState] = useState({
Expand Down Expand Up @@ -70,18 +70,17 @@
).current

useEffect(() => {
if (!inputRef.current?.value) return
debouncedFetchUserList(inputRef.current.value)
}, [inputRef.current?.value])
debouncedFetchUserList(inputValue)
}, [inputValue])

Check warning on line 74 in src/features/group/InviteInput.tsx

View workflow job for this annotation

GitHub Actions / build-and-test

React Hook useEffect has a missing dependency: 'debouncedFetchUserList'. Either include it or remove the dependency array

const handleInputChange = () => {
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setDrop(true)
setInputValue(e.target.value)
}

const handleSelectUser = async (user: Users) => {
setDrop(false)
if (!inputRef.current?.value) return
inputRef.current.value = user.email
setInputValue(user.email)
}

const addUserToList = (user: Users) => {
Expand All @@ -100,9 +99,8 @@
created_at: user.created_at
}
])
if (!inputRef.current?.value) return
inputRef.current.value = ''

setInputValue('')
setDrop(false)
}

Expand Down Expand Up @@ -149,8 +147,7 @@
pendingUser: null
}))

if (!inputRef.current?.value) return
inputRef.current.value = ''
setInputValue('')
}

return (
Expand All @@ -160,15 +157,15 @@
label="이메일"
className=""
onChange={handleInputChange}
ref={inputRef}
value={inputValue}
id="inviteUser"
/>
<AddButton
size="sm"
onClick={() => handleAddUser(inputRef.current?.value, personal)}
onClick={() => handleAddUser(inputValue, personal)}
className="absolute z-1 right-4"
/>
{drop && inputRef.current?.value && (
{drop && inputValue && (
<InviteList
userList={userList}
onSelect={handleSelectUser}
Expand Down
Loading