index.js 696 Bytes
Newer Older
1
import React, { useState, useEffect, useCallback, useRef } from 'react';
张烨's avatar
张烨 committed
2 3 4
import BaseForm from '../../BaseForm';

const SearchBar = props => {
5
  const { items, buttons, onCommit, formProps } = props;
张烨's avatar
张烨 committed
6 7
  const [form, setForm] = useState(null);
  const getForm = f => {
8
    console.log(f);
张烨's avatar
张烨 committed
9 10
    setForm(f);
  };
11 12 13 14
  const handleFinish = values => {
    console.log(values, 'value');
    onCommit(values);
  };
张烨's avatar
张烨 committed
15 16
  useEffect(() => {
    if (form) {
17
      console.log(form.getFieldsValue());
张烨's avatar
张烨 committed
18
    }
19
  }, [form]);
张烨's avatar
张烨 committed
20 21 22 23 24

  return (
    <BaseForm
      items={items}
      buttons={buttons}
25
      formProps={{ ...formProps, onFinish: handleFinish }}
张烨's avatar
张烨 committed
26 27 28 29 30 31
      getForm={getForm}
    />
  );
};

export default SearchBar;