ant-design / pro-table

🏆 Use Ant Design Table like a Pro!
https://protable.ant.design/
MIT License
561 stars 151 forks source link

🐛[BUG]初始化时执行 submit 无效 #303

Open baranwang opened 4 years ago

baranwang commented 4 years ago

🐛 bug 描述

初始化时执行 submit 无效

💻 复现代码 [提供可复现的代码,仓库,或线上示例]

import React, { useRef, useEffect } from "react";
import { request, useLocation } from 'umi';
import ProTable from '@ant-design/pro-table';
import { FormInstance } from 'antd/es/form';

export default () => {
  const formRef = useRef<FormInstance>();
  const location: any = useLocation();
  const { user_id } = location.query;

  useEffect(() => {
    if (!user_id || !formRef.current) return;
    formRef.current.setFieldsValue({ user_id });
    formRef.current.submit();
  }, [user_id]);

  return (
    <ProTable<User>
      formRef={formRef}
      request={async params => {
        const { total, data } = await request("user/", {
          params: {
            ...params,
            limit: params.pageSize,
            page: params.current
          }
        });
        return { data, total };
      }}
      rowKey="id"
      columns={[]}
    ></ProTable>
  );
};

© 版本信息

chenshuai2144 commented 4 years ago

你是想做什么,可以 form还没有初始化成功导致的

baranwang commented 4 years ago

通过获取 url 参数,进行搜索。我看 setFieldsValue 是成功了的, 但是 submit 没有效果

AlanKnightly commented 2 years ago

通过获取 url 参数,进行搜索。我看 setFieldsValue 是成功了的, 但是 submit 没有效果

您好 我们也遇到了这个问题 请问你们有找到解决方法吗?

chenshuai2144 commented 2 years ago

@baranwang form 自带了synctourl的,你用自带的呢