Say I have a badge component I want to add sizing for. This is how I currently do it:
import React from 'react';
import Badge from 'react-bootstrap/Badge';
import classNames from 'classnames';
const BadgeExtended = props => {
const {className, size, ...attr} = props;
const classes = classNames(
className,
size && `badge-${size}`
);
return <Badge className={classes} {...attr}>{props.children}</Badge>;
};
export default BadgeExtended;
which works OK. Is that a correct way to do it? Is there a way to extend the original component so that I dind't have to import an extended one, using react-bootstrap/Badge instead?