Skip to content

Instantly share code, notes, and snippets.

@JoshK2
Last active September 28, 2021 08:29
Show Gist options
  • Save JoshK2/73558d8937cb825e7018f8dfaba160aa to your computer and use it in GitHub Desktop.
Save JoshK2/73558d8937cb825e7018f8dfaba160aa to your computer and use it in GitHub Desktop.
Create React typescript components library - simple button
import React, { Component } from 'react'
import './button.scss'
type State = {}
type Props = {
text?: string,
disable?: boolean,
className?: string,
onClick: Function
}
export default class Button extends Component<Props, State> {
render() {
const { text, disable, className, onClick, children = 'Click' } = this.props
const value = text || children
return (
<button className={disable ? `disable ${className}` : className} onClick={(e) => onClick(e)}>{value}</button>
)
}
}
@hurmantrout
Copy link

great! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment