账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    React class 类型组件 转 函数化的 Hooks
    18
    0

    大致学习了 函数化的 Hooks例子,实际操作还是蒙。若把一处理解透了,可能也就行了。比如<Modal>标签的提交和重置.interface直接拿过来就行,原来的props怎么写呢?

    const [abcxxx, setxxx] = useState<boolean>(true);

    class 类型组件:

    interface CreateFormProps extends FormComponentProps {
      modalVisible: boolean;
      onSubmit: (fieldsValue: { desc: string }) => void;
      onCancel: () => void;
    }
    
    const CreateForm: React.FC<CreateFormProps> = props => {
      const { modalVisible, form, onSubmit: handleAdd, onCancel } = props;
      const okHandle = () => {
        form.validateFields((err, fieldsValue) => {
          if (err) return;
          form.resetFields();
          handleAdd(fieldsValue);
        });
      };
      const handleSubmit = () => {
        props.form.validateFields((err, values) => {
          if (!err) {
            console.log('Received values of form: ', values);
          }
        });
      };
      
      return (
        <Modal
          width={940}
          destroyOnClose
          title="新建规则"
          visible={modalVisible}
          onOk={okHandle}
          onCancel={() => onCancel()}
          maskClosable={false}
          cancelText={'重置'}
          okText={'提交'}
        >
        ...省略
    0
    打赏
    收藏
    点击回答
    您的回答被采纳后将获得:提问者悬赏的 10 元积分
        全部回答
    • 0
    • 独爱流浪 普通会员 1楼
      502 Bad Gateway

      502 Bad Gateway


      nginx
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部