Skip to content

Instantly share code, notes, and snippets.

@moonhopark
Created February 15, 2023 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moonhopark/f7eebd80114c7f9b2069bc088fe867a5 to your computer and use it in GitHub Desktop.
Save moonhopark/f7eebd80114c7f9b2069bc088fe867a5 to your computer and use it in GitHub Desktop.
const InputComponent = ({ id, type, placeholder, isRequired, name }) => {
return (
<div className="InputComponent">
<label for={id}>{name}</label>
{isRequired && <span className="required">필수</span>{" "}}
<br />
<input
id={id}
type={type}
placeholder={placeholder}
required={isRequired}
className="app-input"
/>
</div>
);
};
// props로 받은 isRequired에 따라서 달라지는 부분이 input 속성의 required와 필수 span 태그 부분밖에 없는 것으로 보이네요.
// span 태그는 && 연산자를 사용해서 isReuiqred가 true 일때만 보여주면 될 것 같아요.
// input 태그의 required 속성도 isReuiqred를 넘겨주면 될 것 같아요.
// 제가 실행해보지는 않고 간단하게 수정해보았으니 직접 수정해보시고 잘 돌아가는지 확인해보시면 될 것 같아요.
// 질문 있으시면 언제든지 편하게 주세요!!
export default InputComponent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment