Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to create a button with react

import PropTypes from 'prop-types'

const Button = ({ color, text, onClick }) => {
    return (
    <button 
        onClick={onClick}
        style={{backgroundColor: color}} 
        className='btn'>
        {text}
    </button>
    )
}

Button.defaultrops = {
    color: 'steelblue'
}

Button.propTypes = {
    text: PropTypes.string,
    color:PropTypes.string,
    onClick: PropTypes.func,
}

export default Button
 
PREVIOUS NEXT
Tagged: #create #button #react
ADD COMMENT
Topic
Name
9+4 =