Button Component - React + Typescript

PHOTO EMBED

Tue Jun 14 2022 12:21:09 GMT+0000 (Coordinated Universal Time)

Saved by @jen_magpantay #javascript #react.js

import React from "react";

interface Props {
  style?: string;
  type: "button" | "submit" | "reset";
  title?: string;
  icon?: React.ReactNode;
  onClick: () => void;
}

// Button component could accept text, icons and/or styles as props
// style and onClick props are mandatory
export const Button = ({ style, type, title, icon, onClick }: Props) => {
  return (
    <button className={style} type={type} onClick={onClick}>
      <span>{icon}</span>
      {title}
    </button>
  );
};
content_copyCOPY