본문 바로가기

React.JS

react-hook-form onBlur 안될때

  • onBlur가 왜 안먹히나 보았더니 react-hook-form 에서 register를 등록할때 이미 onBlur가 props로 내려가고 있었다. 그레서 {…rest}의 위치를 맨 앞으로 옮겨주고 내가 만든 onBlur를 뒤로 빼주었더니 우선순위가 내가 만든 onBlur로 가게 되어서 작동하였다.
<Wrapper>
      <Label focused={focused}>{label}</Label>
      <Input {...rest} onFocus={onFocus} onBlur={onBlur} ref={ref} />
</Wrapper>