Skip to content

Commit

Permalink
Refactor prop destructuring
Browse files Browse the repository at this point in the history
  • Loading branch information
tcbegley committed Feb 11, 2024
1 parent 3386dd9 commit 08e85c6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
24 changes: 7 additions & 17 deletions src/components/breadcrumb/Breadcrumb.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,17 @@ import {sanitizeAndCheckUrl} from '../../private/util';
* Use breadcrumbs to create a navigation breadcrumb in your app.
*/

const BreadcrumbItem = ({
item,
idx,
item_class_name,
itemClassName,
setProps
}) => {
const sanitizedUrl = sanitizeAndCheckUrl(item.href, setProps);
const BreadcrumbItem = ({href, setProps, external_link, label, ...otherProps}) => {
const sanitizedUrl = sanitizeAndCheckUrl(href, setProps);

return (
<RBBreadcrumb.Item
key={`${item.value}${idx}`}
active={item.active}
linkAs={sanitizedUrl && Link}
className={item_class_name || itemClassName}
href={sanitizedUrl}
linkProps={sanitizedUrl && {external_link: item.external_link}}
linkProps={sanitizedUrl && { external_link }}
{...otherProps}
>
{item.label}
{label}
</RBBreadcrumb.Item>
);
};
Expand Down Expand Up @@ -55,11 +47,9 @@ const Breadcrumb = ({
{(items || []).map((item, idx) => (
<BreadcrumbItem
key={`${item.value}${idx}`}
idx={idx}
item={item}
item_class_name={item_class_name}
itemClassName={itemClassName}
className={item_class_name || itemClassName}
setProps={setProps}
{...item}
/>
))}
</RBBreadcrumb>
Expand Down
2 changes: 1 addition & 1 deletion src/components/card/CardLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const CardLink = props => {
disabled={disabled}
href={sanitizedUrl}
className={class_name || className}
{...omit(['setProps', 'n_clicks', 'n_clicks_timestamp'], otherProps)}
{...omit(['n_clicks', 'n_clicks_timestamp'], otherProps)}
>
{children}
</RBCard.Link>
Expand Down
14 changes: 11 additions & 3 deletions src/components/nav/NavbarBrand.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ import {sanitizeAndCheckUrl} from '../../private/util';
* Call out attention to a brand name or site title within a navbar.
*/
const NavbarBrand = props => {
const {children, loading_state, className, class_name, ...otherProps} = props;
const sanitizedUrl = sanitizeAndCheckUrl(props.href, props.setProps);
const {
children,
loading_state,
className,
class_name,
href,
setProps,
...otherProps
} = props;
const sanitizedUrl = sanitizeAndCheckUrl(href, setProps);
return (
<RBNavbarBrand
className={class_name || className}
{...omit(['setProps'], otherProps)}
{...otherProps}
as={sanitizedUrl ? Link : 'span'}
href={sanitizedUrl}
data-dash-is-loading={
Expand Down

0 comments on commit 08e85c6

Please sign in to comment.