Skip to content

How to use ButtonProps["onClick"] for onclick #30914

Closed Answered by pradeept95
Ofer-Gal asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @Ofer-Gal
Here is the example in typescript!

import * as React from 'react';
import { Button } from '@fluentui/react-components';
import type { ButtonProps } from '@fluentui/react-components';

export const Default = () => {
  const handleClick: ButtonProps['onClick'] = (
    e: React.MouseEvent<HTMLButtonElement>
  ) => {
    console.log(e);
    alert('clicked');
  };

  return <Button onClick={handleClick}>Example</Button>;
};

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Ofer-Gal
Comment options

Answer selected by khmakoto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants