Skip to content

Commit 6b20236

Browse files
committed
convert defaultProps to default assignments in functional components.
1 parent 206e6ec commit 6b20236

File tree

8 files changed

+55
-100
lines changed

8 files changed

+55
-100
lines changed

code/ui/blocks/src/components/Source.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const Source: FunctionComponent<SourceProps> = ({
9898
language,
9999
code,
100100
dark,
101-
format,
101+
format = false,
102102
...rest
103103
}) => {
104104
const { typography } = useTheme();
@@ -138,7 +138,4 @@ const Source: FunctionComponent<SourceProps> = ({
138138
);
139139
};
140140

141-
Source.defaultProps = {
142-
format: false,
143-
};
144141
export { Source, StyledSyntaxHighlighter };

code/ui/components/src/components/form/field/field.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,3 @@ export const Field = ({ label, children, ...props }: FieldProps) => (
3838
{children}
3939
</Wrapper>
4040
);
41-
42-
Field.defaultProps = {
43-
label: undefined,
44-
};

code/ui/components/src/components/tabs/tabs.tsx

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ export interface TabsProps {
134134
export const Tabs: FC<TabsProps> = memo(
135135
({
136136
children,
137-
selected,
137+
selected = null,
138138
actions,
139-
absolute,
140-
bordered,
141-
tools,
139+
absolute = false,
140+
bordered = false,
141+
tools = null,
142142
backgroundColor,
143-
id: htmlId,
144-
menuName,
143+
id: htmlId = null,
144+
menuName = 'Tabs',
145145
emptyState,
146146
showToolsWhenEmpty,
147147
}) => {
@@ -206,15 +206,6 @@ export const Tabs: FC<TabsProps> = memo(
206206
}
207207
);
208208
Tabs.displayName = 'Tabs';
209-
Tabs.defaultProps = {
210-
id: null,
211-
children: null,
212-
tools: null,
213-
selected: null,
214-
absolute: false,
215-
bordered: false,
216-
menuName: 'Tabs',
217-
};
218209

219210
export interface TabsStateProps {
220211
children: TabsProps['children'];

code/ui/components/src/components/tooltip/ListItem.tsx

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -186,17 +186,18 @@ export interface ListItemProps extends Omit<ComponentProps<typeof Item>, 'href'
186186
}
187187

188188
const ListItem = ({
189-
loading,
190-
title,
191-
center,
192-
right,
193-
icon,
194-
active,
195-
disabled,
189+
loading = false,
190+
title = <span>Loading state</span>,
191+
center = null,
192+
right = null,
193+
194+
active = false,
195+
disabled = false,
196196
isIndented,
197-
href,
198-
onClick,
199-
LinkWrapper,
197+
href = null,
198+
onClick = null,
199+
icon,
200+
LinkWrapper = null,
200201
...rest
201202
}: ListItemProps) => {
202203
const itemProps = getItemProps(onClick, href, LinkWrapper);
@@ -220,16 +221,4 @@ const ListItem = ({
220221
);
221222
};
222223

223-
ListItem.defaultProps = {
224-
loading: false,
225-
title: <span>Loading state</span>,
226-
center: null,
227-
right: null,
228-
active: false,
229-
disabled: false,
230-
href: null,
231-
LinkWrapper: null,
232-
onClick: null,
233-
};
234-
235224
export default ListItem;

code/ui/components/src/components/tooltip/Tooltip.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,16 @@ export interface TooltipProps {
126126

127127
export const Tooltip = React.forwardRef<HTMLDivElement, TooltipProps>(
128128
(
129-
{ placement, hasChrome, children, arrowProps, tooltipRef, color, withArrows, ...props },
129+
{
130+
placement = 'top',
131+
hasChrome = true,
132+
children,
133+
arrowProps = {},
134+
tooltipRef,
135+
color,
136+
withArrows,
137+
...props
138+
},
130139
ref
131140
) => {
132141
return (
@@ -139,10 +148,3 @@ export const Tooltip = React.forwardRef<HTMLDivElement, TooltipProps>(
139148
);
140149

141150
Tooltip.displayName = 'Tooltip';
142-
Tooltip.defaultProps = {
143-
color: undefined,
144-
tooltipRef: undefined,
145-
hasChrome: true,
146-
placement: 'top',
147-
arrowProps: {},
148-
};

code/ui/components/src/components/tooltip/TooltipLinkList.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export interface TooltipLinkListProps {
5858
LinkWrapper?: LinkWrapperType;
5959
}
6060

61-
export const TooltipLinkList = ({ links, LinkWrapper }: TooltipLinkListProps) => {
61+
export const TooltipLinkList = ({ links, LinkWrapper = null }: TooltipLinkListProps) => {
6262
const hasIcon = links.some((link) => link.icon);
6363
return (
6464
<List>
@@ -68,7 +68,3 @@ export const TooltipLinkList = ({ links, LinkWrapper }: TooltipLinkListProps) =>
6868
</List>
6969
);
7070
};
71-
72-
TooltipLinkList.defaultProps = {
73-
LinkWrapper: ListItem.defaultProps.LinkWrapper,
74-
};

code/ui/components/src/components/tooltip/TooltipMessage.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,3 @@ export const TooltipMessage = ({ title, desc, links }: TooltipMessageProps) => {
6060
</MessageWrapper>
6161
);
6262
};
63-
64-
TooltipMessage.defaultProps = {
65-
title: null,
66-
desc: null,
67-
links: null,
68-
};

code/ui/components/src/components/tooltip/WithTooltip.tsx

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,42 @@ export interface WithTooltipPureProps
4545

4646
// Pure, does not bind to the body
4747
const WithTooltipPure = ({
48-
svg,
49-
trigger,
50-
closeOnOutsideClick,
51-
placement,
52-
hasChrome,
48+
svg = false,
49+
trigger = 'click',
50+
closeOnOutsideClick = false,
51+
placement = 'top',
52+
modifiers = [
53+
{
54+
name: 'preventOverflow',
55+
options: {
56+
padding: 8,
57+
},
58+
},
59+
{
60+
name: 'offset',
61+
options: {
62+
offset: [8, 8],
63+
},
64+
},
65+
{
66+
name: 'arrow',
67+
options: {
68+
padding: 8,
69+
},
70+
},
71+
],
72+
hasChrome = true,
73+
defaultVisible = false,
5374
withArrows,
5475
offset,
5576
tooltip,
5677
children,
5778
closeOnTriggerHidden,
5879
mutationObserverOptions,
59-
defaultVisible,
6080
delayHide,
6181
visible,
6282
interactive,
6383
delayShow,
64-
modifiers,
6584
strategy,
6685
followCursor,
6786
onVisibleChange,
@@ -120,35 +139,6 @@ const WithTooltipPure = ({
120139
);
121140
};
122141

123-
WithTooltipPure.defaultProps = {
124-
svg: false,
125-
trigger: 'click',
126-
closeOnOutsideClick: false,
127-
placement: 'top',
128-
modifiers: [
129-
{
130-
name: 'preventOverflow',
131-
options: {
132-
padding: 8,
133-
},
134-
},
135-
{
136-
name: 'offset',
137-
options: {
138-
offset: [8, 8],
139-
},
140-
},
141-
{
142-
name: 'arrow',
143-
options: {
144-
padding: 8,
145-
},
146-
},
147-
],
148-
hasChrome: true,
149-
defaultVisible: false,
150-
};
151-
152142
export interface WithTooltipStateProps extends Omit<WithTooltipPureProps, 'onVisibleChange'> {
153143
startOpen?: boolean;
154144
onVisibleChange?: (visible: boolean) => void | boolean;

0 commit comments

Comments
 (0)