Search code examples
reactjsevent-handlingantd

Antd Custom button not triggering dropdown


Can someone explain to me why the dropdown trigger is not being executed when I use my custom button? Where do I declare OnClick as I use CustomButton in other areas

Edit empty-microservice-4xhjr


Solution

  • Dropdown of Antd passes a prop called onClick to its children CustomButton, and you need to pass it to the button inside CustomButton:

    const CustomButton = props => {
      return <Button type={props.type} onClick={props.onClick}>{props.text}</Button>;
    };
    

    Demo