Skip to content

Commit e34ce53

Browse files
committed
fix: SignupTextField의 검증 로직을 렌더 외부로 분리
1 parent 6e29cb5 commit e34ce53

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/common/component/TextField/signup/SignupTextField.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,24 +68,24 @@ const SignupTextField = ({
6868
[onChange, variant],
6969
);
7070

71+
const signupType = variant === 'email' ? undefined : (variant as 'name' | 'birth' | 'job');
72+
let computedInvalid: boolean | undefined;
73+
let computedError: string | undefined;
74+
if (signupType) {
75+
const msg = validateSignupField(signupType, value);
76+
if (msg) {
77+
computedInvalid = true;
78+
computedError = msg;
79+
}
80+
}
81+
7182
return (
7283
<BaseTextField id={id} value={value} onChange={handleChange} disabled={disabled}>
7384
{({ inputProps, hasValue, isFocused, clear }) => {
7485
const state = computeFieldState({ hasValue, isFocused, isHovered, disabled: !!disabled });
7586
const wrapperClass = s.fieldBox[state];
7687
const inputClass = s.inputState[state];
7788

78-
let computedInvalid: boolean | undefined;
79-
let computedError: string | undefined;
80-
const signupType = variant === 'email' ? undefined : (variant as 'name' | 'birth' | 'job');
81-
if (signupType) {
82-
const msg = validateSignupField(signupType, value);
83-
if (msg) {
84-
computedInvalid = true;
85-
computedError = msg;
86-
}
87-
}
88-
8989
return (
9090
<div
9191
className={computedInvalid ? s.errorContainer : undefined}

0 commit comments

Comments
 (0)