Skip to content

Commit

Permalink
⚡️:: #7 비밀번호 타입 관리하는 커스텀 훅스 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
hyosin-Jang committed Mar 6, 2022
1 parent a51c221 commit d143d61
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/hooks/usePassword.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { useState, useCallback } from 'react';

const usePassword = (initialForm: any) => {
const [form, setForm] = useState(initialForm);

const handlePasswordType = useCallback(() => {
setForm(() => {
if (!form.visible) {
return { type: 'text', visible: true };
}
return { type: 'password', visible: false };
});
}, []);
return [form, handlePasswordType];
};
export default usePassword;

0 comments on commit d143d61

Please sign in to comment.