React PropType and DefaultProp

PHOTO EMBED

Sat Dec 24 2022 11:11:21 GMT+0000 (Coordinated Universal Time)

Saved by @Abizareei #react.js

import React from "react"
import PropTypes from "prop-types"
import ThemeContext from "./themeContext"

function Button(props) {
    return (
        <button className={`${props.theme}-theme`}>Switch Theme</button>
    )    
}

Button.propTypes = {
    theme: PropTypes.oneOf(["light", "dark"])
}

Button.defaultProps = {
    theme: "light"
}
content_copyCOPY