Aikodev-labs / Ghibli-API-platform

https://ghibli-api-platform.vercel.app
5 stars 0 forks source link

GA-026 (FE) Crear un componente button #34

Open joshuacba08 opened 1 year ago

joshuacba08 commented 1 year ago

Necesitamos crear un componente button para usar en distintas partes de la aplicación.

   <Button title="Buy now"  color="primary" disable="true" handleclick={ onAdd } />

  import PropTypes from 'prop-types';
  import './Button.css';
const Button = (props) => {
    return (
        <button
            className={`button button-${props.color}`}
            onClick={ props.handleClick }
        >
            {props.title}
        </button>
    )
}
Button.propTypes = { // Validating the props passed to the component
    title: PropTypes.string,
    color: PropTypes.string,
    handleClick: [PropTypes.func]  // si tira un error en consola, sacar el handleClick o todo el proptype
}
export default Button;