InfoInput.jsx
import React from 'react'
export default function InputAndWarn({
type,
placeHolder,
pattern,
label,
required,
minlength,
maxlength,
onBlur
}) {
if (required) {
return (
<label>
<span>{label}</span>
{/* onFocus의 경우 어떤 곳에서든 기본적으로 작동하는 것일 때 */}
<input
type={type}
placeholder={placeHolder}
pattern={pattern}
minLength={minlength}
maxLength={maxlength}
onBlur={onBlur}
onFocus={(e) => {e.target.style.backgroundColor="red"}}
required
/>
</label>
)
} else {
return (
<label>
<span>{label}</span>
{/* onFocus의 경우 어떤 곳에서든 기본적으로 작동하는 것일 때 */}
<input
type={type}
placeholder={placeHolder}
pattern={pattern}
minLength={minlength}
maxLength={maxlength}
onBlur={onBlur}
onFocus={(e) => {e.target.style.backgroundColor="red"}}
/>
</label>
)
}
}
JavaScript
복사