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

+ Recent posts