@drawbotics/enums
v0.2.0
Published
A small utility to create reliable enums.
Downloads
4
Keywords
Readme
Enums
A small utility to create reliable enums.
Installation
$ npm i @drawbotics/enums
Usage
import Enum from '@drawbotics/enums';
import PropTypes from 'prop-types';
const Categories = new Enum('PRIMARY', 'SECONDARY');
const Button = ({ category, children }) => {
return (
<button className={category === Categories.PRIMARY ? 'primary' : 'secondary'}>
{children}
</button>
);
};
Button.propTypes = {
category: PropTypes.oneOf(Object.keys(Categories)),
};
export default Button;