import { memo } from 'react';
import classNames from 'classnames/bind';
import styles from './Button.module.scss';
const cn = classNames.bind(styles);
const Button = memo(
({ design: { size, color, outline, hover }, content, type, onClick }) => (
<button
type={type}
className={cn('button', size, color, { outline }, { hover })}
onClick={onClick}
>
{content}
</button>
)
);
Button.defaultProps = {
size: 'md',
color: 'black',
};
export default Button;
defaultProps
doesn't work in this case. If I set default value when destructuring props like:
{ design: { size='md', color='black', outline, hover }, content, type, onClick }
, it works.
I passed the props:
<Button
design={{ size: 'sm', outline: true }}
content="Edit"
onClick={onEditClick}
/>
What's wrong here?