Skip to content

Commit 5ad2be3

Browse files
committed
Refactor prop destructuring
1 parent 3386dd9 commit 5ad2be3

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

src/components/breadcrumb/Breadcrumb.js

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,17 @@ import {sanitizeAndCheckUrl} from '../../private/util';
99
* Use breadcrumbs to create a navigation breadcrumb in your app.
1010
*/
1111

12-
const BreadcrumbItem = ({
13-
item,
14-
idx,
15-
item_class_name,
16-
itemClassName,
17-
setProps
18-
}) => {
19-
const sanitizedUrl = sanitizeAndCheckUrl(item.href, setProps);
12+
const BreadcrumbItem = ({href, setProps, external_link, label, ...otherProps}) => {
13+
const sanitizedUrl = sanitizeAndCheckUrl(href, setProps);
2014

2115
return (
2216
<RBBreadcrumb.Item
23-
key={`${item.value}${idx}`}
24-
active={item.active}
2517
linkAs={sanitizedUrl && Link}
26-
className={item_class_name || itemClassName}
2718
href={sanitizedUrl}
28-
linkProps={sanitizedUrl && {external_link: item.external_link}}
19+
linkProps={sanitizedUrl && { external_link }}
20+
{...otherProps}
2921
>
30-
{item.label}
22+
{label}
3123
</RBBreadcrumb.Item>
3224
);
3325
};
@@ -55,11 +47,9 @@ const Breadcrumb = ({
5547
{(items || []).map((item, idx) => (
5648
<BreadcrumbItem
5749
key={`${item.value}${idx}`}
58-
idx={idx}
59-
item={item}
60-
item_class_name={item_class_name}
61-
itemClassName={itemClassName}
50+
className={item_class_name || itemClassName}
6251
setProps={setProps}
52+
{...item}
6353
/>
6454
))}
6555
</RBBreadcrumb>

src/components/card/CardLink.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const CardLink = props => {
4242
disabled={disabled}
4343
href={sanitizedUrl}
4444
className={class_name || className}
45-
{...omit(['setProps', 'n_clicks', 'n_clicks_timestamp'], otherProps)}
45+
{...omit(['n_clicks', 'n_clicks_timestamp'], otherProps)}
4646
>
4747
{children}
4848
</RBCard.Link>

src/components/nav/NavbarBrand.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,20 @@ import {sanitizeAndCheckUrl} from '../../private/util';
99
* Call out attention to a brand name or site title within a navbar.
1010
*/
1111
const NavbarBrand = props => {
12-
const {children, loading_state, className, class_name, ...otherProps} = props;
13-
const sanitizedUrl = sanitizeAndCheckUrl(props.href, props.setProps);
12+
const {
13+
children,
14+
loading_state,
15+
className,
16+
class_name,
17+
href,
18+
setProps,
19+
...otherProps
20+
} = props;
21+
const sanitizedUrl = sanitizeAndCheckUrl(href, setProps);
1422
return (
1523
<RBNavbarBrand
1624
className={class_name || className}
17-
{...omit(['setProps'], otherProps)}
25+
{...otherProps}
1826
as={sanitizedUrl ? Link : 'span'}
1927
href={sanitizedUrl}
2028
data-dash-is-loading={

0 commit comments

Comments
 (0)