Skip to content

Commit 9ab0879

Browse files
authored
chore: drop default-props (#374)
1 parent 0dfe964 commit 9ab0879

File tree

4 files changed

+61
-71
lines changed

4 files changed

+61
-71
lines changed

packages/react/src/components/Card/CardWrap.js

+27-22
Original file line numberDiff line numberDiff line change
@@ -78,29 +78,34 @@ const Element = styled('a')(
7878
contrast && (!color || !backgroundColor) && hoverStyle
7979
)
8080

81-
const CardWrap = forwardRef(({ href, rel, target, ...restProps }, ref) => {
82-
const {
83-
state: { backgroundColor, color, title },
84-
props: { size: $cardSize }
85-
} = useContext(GlobalContext)
86-
87-
return createElement(Element, {
88-
...(restProps.as === 'a' ? { href, rel, target } : undefined),
89-
...restProps,
90-
backgroundColor,
91-
$cardSize,
92-
color,
93-
ref,
94-
title
95-
})
96-
})
81+
const CardWrap = forwardRef(
82+
(
83+
{
84+
href,
85+
rel = 'noopener noreferrer',
86+
target = '_blank',
87+
as = 'a',
88+
...restProps
89+
},
90+
ref
91+
) => {
92+
const {
93+
state: { backgroundColor, color, title },
94+
props: { size: $cardSize }
95+
} = useContext(GlobalContext)
96+
97+
return createElement(Element, {
98+
...(as === 'a' ? { href, rel, target } : undefined),
99+
...restProps,
100+
backgroundColor,
101+
$cardSize,
102+
color,
103+
ref,
104+
title
105+
})
106+
}
107+
)
97108

98109
CardWrap.displayName = 'CardWrap'
99110

100-
CardWrap.defaultProps = {
101-
as: 'a',
102-
rel: 'noopener noreferrer',
103-
target: '_blank'
104-
}
105-
106111
export default CardWrap

packages/react/src/index.js

+32-17
Original file line numberDiff line numberDiff line change
@@ -209,25 +209,40 @@ microlink.io/${error.code.toLowerCase()}
209209
)
210210
}
211211

212-
const Microlink = props => (
213-
<GlobalState {...props}>{otherProps => <Card {...otherProps} />}</GlobalState>
212+
const Microlink = ({
213+
className = '',
214+
apiKey = undefined,
215+
autoPlay = true,
216+
controls = true,
217+
direction = 'ltr',
218+
lazy = true,
219+
loop = true,
220+
media = ['iframe', 'video', 'audio', 'image', 'logo'],
221+
fetchData = true,
222+
muted = true,
223+
playsInline = true,
224+
size = 'normal',
225+
...props
226+
}) => (
227+
<GlobalState
228+
className={className}
229+
apiKey={apiKey}
230+
autoPlay={autoPlay}
231+
controls={controls}
232+
direction={direction}
233+
lazy={lazy}
234+
loop={loop}
235+
media={media}
236+
fetchData={fetchData}
237+
muted={muted}
238+
playsInline={playsInline}
239+
size={size}
240+
{...props}
241+
>
242+
{otherProps => <Card {...otherProps} />}
243+
</GlobalState>
214244
)
215245

216-
Microlink.defaultProps = {
217-
className: '',
218-
apiKey: undefined,
219-
autoPlay: true,
220-
controls: true,
221-
direction: 'ltr',
222-
lazy: true,
223-
loop: true,
224-
media: ['iframe', 'video', 'audio', 'image', 'logo'],
225-
fetchData: true,
226-
muted: true,
227-
playsInline: true,
228-
size: 'normal'
229-
}
230-
231246
Microlink.propTypes = {
232247
apiKey: PropTypes.string,
233248
autoPlay: PropTypes.bool,

packages/react/test/snapshots/build.mjs.md

+2-32
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,7 @@ Generated by [AVA](https://avajs.dev).
1010
1111
`{␊
1212
fetchFromApi: [Getter],␊
13-
default: [Function: Microlink] {␊
14-
defaultProps: {␊
15-
className: '',␊
16-
apiKey: undefined,␊
17-
autoPlay: true,␊
18-
controls: true,␊
19-
direction: 'ltr',␊
20-
lazy: true,␊
21-
loop: true,␊
22-
media: [Array],␊
23-
fetchData: true,␊
24-
muted: true,␊
25-
playsInline: true,␊
26-
size: 'normal'␊
27-
}␊
28-
},␊
13+
default: [Function: Microlink],␊
2914
getApiUrl: [Function: getApiUrl],␊
3015
imageProxy: [Function: imageProxy]␊
3116
}`
@@ -35,22 +20,7 @@ Generated by [AVA](https://avajs.dev).
3520
> Snapshot 1
3621
3722
`[Module: null prototype] {␊
38-
default: [Function: Microlink] {␊
39-
defaultProps: {␊
40-
className: '',␊
41-
apiKey: undefined,␊
42-
autoPlay: true,␊
43-
controls: true,␊
44-
direction: 'ltr',␊
45-
lazy: true,␊
46-
loop: true,␊
47-
media: [Array],␊
48-
fetchData: true,␊
49-
muted: true,␊
50-
playsInline: true,␊
51-
size: 'normal'␊
52-
}␊
53-
},␊
23+
default: [Function: Microlink],␊
5424
fetchFromApi: [AsyncFunction: fetchFromApi],␊
5525
getApiUrl: [Function: getApiUrl],␊
5626
imageProxy: [Function: imageProxy]␊
-128 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)