이제 AuthForm에서 type props에 따라 다른 내용을 보여 주도록 수정해 봅시다. type 값에 따라 사용되는 문구도 달라지고, type'register'일 때는 비밀번호 확인 인풋도 보여 줍니다.

    components/auth/AuthForm.js - AuthForm

    const textMap = {
      login: '로그인',
      register: '회원가입',
    };
    
    const AuthForm = ({ type }) => {
      const text = textMap[type];
      return (
        <AuthFormBlock>
          <h3>{text}</h3>
          <form>
            <StyledInput autoComplete="username" name="username" placeholder="아이디" />
            <StyledInput 
              autoComplete="new-password" 
              name="password" 
              placeholder="비밀번호" 
              type="password" 
            />
            {type = = = 'register' && (
              <StyledInput
                autoComplete="new-password" 
                name="passwordConfirm"
                placeholder="비밀번호 확인"
                type="password"
              />
            )}
            <ButtonWithMarginTop cyan fullWidth style={{ marginTop: '1rem' }}>
              {text}
            </ButtonWithMarginTop>
          </form>
          <Footer>
            {type = = = 'login' ? (
              <Link to="/register">회원가입</Link>
            ) : (
              <Link to="/login">로그인</Link>
            )}
          </Footer>
        </AuthFormBlock>
      );
    };
    
    export default AuthForm;

    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.