Skip to content

Instantly share code, notes, and snippets.

@sabesansathananthan
Created December 4, 2019 08:39
Show Gist options
  • Save sabesansathananthan/381675679870771c3b9f3f59403df44b to your computer and use it in GitHub Desktop.
Save sabesansathananthan/381675679870771c3b9f3f59403df44b to your computer and use it in GitHub Desktop.
React best Practice default props example
import React, { Component } from "react";
import { Button } from "react-bootstrap";
import PropTypes from 'prop-types'
class ModalButton extends Component {
render() {
return <Button variant={this.props.variant}>{this.props.children}</Button>;
}
}
ModalButton.defaultProps = {
variant: "outline-info",
children: "Info"
};
ModalButton.propTypes = {
variant: PropTypes.string,
children: PropTypes.string
}
ReactDOM.render(<ModalButton />, document.getElementById('root'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment