Skip to content

Instantly share code, notes, and snippets.

@jx13xx
Created February 6, 2022 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jx13xx/fad3052345e3a3982558cb8c7f14cd9d to your computer and use it in GitHub Desktop.
Save jx13xx/fad3052345e3a3982558cb8c7f14cd9d to your computer and use it in GitHub Desktop.
Custom Button React Component
return (
<Card>
<form>
<h2> How you rate your service with us?</h2>
<div className={'input-group'}>
<input
onChange={handleTextChange}
type={'text'}
placeholder={'Write a review'}
value={text}/>
<Button
type={'submit'}
version={'secondary'}
// onClick={handleSubmitButton}
>Send</Button>
</div>
</form>
</Card>
);
import React from 'react';
import PropTypes from 'prop-types';
function Button({children, version, type, isDisabled}) {
return (
<button type={type} disabled={isDisabled} className={`btn btn-${version}`}>{children}</button>
);
}
Button.defaultProps = {
version: 'primary',
type: 'button',
isDisabled: false
}
Button.propTypes = {
children: PropTypes.node.isRequired,
version: PropTypes.string,
type: PropTypes.string,
isDisabled: PropTypes.bool
};
export default Button;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment