728x90
antd form을 사용할 때, 특정 input의 값을 reset하고 싶을 때가 있다.
예를 들어, 아래와 같이 'password'라는 name을 가진 Input을 reset 시키고 싶다면,
<Form.Item
name="password"
label="비밀번호"
rules={[
{
required: true,
message: '비밀번호를 입력해주세요!',
},
]}
hasFeedback
>
<Input.Password placeholder="비밀번호를 입력해주세요" />
</Form.Item>
다음과 같이 form.setFieldsValue 안에서 password(Form.Item의 name) : ''로 바꿔주면 된다.
form.setFieldsValue({
password: '',
});
728x90
'TIL_개발일기' 카테고리의 다른 글
[TIL] useCallback 의존성 배열 안에 언제 값을 넣어야 할까? (0) | 2021.04.21 |
---|---|
[TIL_개발일기_210414] [css] active와 focus의 차이 (0) | 2021.04.15 |
[TIL_개발일기_210413] a 클릭 영역 늘리기 / next에서 router.push()와 Link의 차이 (0) | 2021.04.13 |
[TIL_개발일기_210405] axios.defaults.baseurl / findOne (0) | 2021.04.06 |
[TIL_개발일기_210326] table width 고정, 자동 줄바꿈 (0) | 2021.03.26 |