FormListButtonDiy.js 665 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
import { Button } from 'antd';
import React, { useState, useEffect } from 'react';

export function FormListButtonDiy(props) {
  const [stateProps, setProps] = useState({ ...props });
  useEffect(() => {
    if (props.changeButtonProps && typeof props.changeButtonProps === 'function') {
      props.changeButtonProps({
        selectedRows: props.selectedRows,
        setProps,
        stateProps,
      });
    }
  }, [props.selectedRows]);

  const handleClick = e => {
    if (props.onClick && typeof props.onClick === 'function') {
      props.onClick(e, props.selectedRows, props.obj);
    }
  };
  return <Button {...stateProps} onClick={handleClick} />;
}