Button.tsx
import React from "react";
interface ButtonProps {
name: string;
onButtonClick: () => void;
}
function Button(props: ButtonProps) {
const { name, onButtonClick } = props;
function buttonAlert() {
alert(`Testing`);
}
return (
<div>
<button className="buttonOne" onClick={buttonAlert}>{name}</button>
</div>
);
}
export default Button;
index.tsx
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import Button from './Button';
ReactDOM.render(
<React.StrictMode>
<App />
<Button name="Button One" onButtonClick={() => { alert(`You clicked on Button One!