Skip to content

Commit 2d082ec

Browse files
committed
Remove defaultProps (use default parameters)
This fixes React warnings: "Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead."
1 parent 0a2d7e8 commit 2d082ec

File tree

5 files changed

+7
-53
lines changed

5 files changed

+7
-53
lines changed

packages/component/src/BasicScrollToBottom.js

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@ const BasicScrollToBottomCore = ({ children, className, followButtonClassName, s
2222
);
2323
};
2424

25-
BasicScrollToBottomCore.defaultProps = {
26-
children: undefined,
27-
className: undefined,
28-
followButtonClassName: undefined,
29-
scrollViewClassName: undefined
30-
};
31-
3225
BasicScrollToBottomCore.propTypes = {
3326
children: PropTypes.any,
3427
className: PropTypes.string,
@@ -43,7 +36,7 @@ const BasicScrollToBottom = ({
4336
debounce,
4437
debug,
4538
followButtonClassName,
46-
initialScrollBehavior,
39+
initialScrollBehavior = 'smooth',
4740
mode,
4841
nonce,
4942
scroller,
@@ -68,20 +61,6 @@ const BasicScrollToBottom = ({
6861
</Composer>
6962
);
7063

71-
BasicScrollToBottom.defaultProps = {
72-
checkInterval: undefined,
73-
children: undefined,
74-
className: undefined,
75-
debounce: undefined,
76-
debug: undefined,
77-
followButtonClassName: undefined,
78-
initialScrollBehavior: 'smooth',
79-
mode: undefined,
80-
nonce: undefined,
81-
scroller: undefined,
82-
scrollViewClassName: undefined
83-
};
84-
8564
BasicScrollToBottom.propTypes = {
8665
checkInterval: PropTypes.number,
8766
children: PropTypes.any,

packages/component/src/EventSpy.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useCallback, useLayoutEffect, useMemo, useRef } from 'react';
22

33
import debounceFn from './debounce';
44

5-
const EventSpy = ({ debounce, name, onEvent, target }) => {
5+
const EventSpy = ({ debounce = 200, name, onEvent, target }) => {
66
// We need to save the "onEvent" to ref.
77
// This is because "onEvent" may change from time to time, but debounce may still fire to the older callback.
88
const onEventRef = useRef();
@@ -38,8 +38,4 @@ const EventSpy = ({ debounce, name, onEvent, target }) => {
3838
return false;
3939
};
4040

41-
EventSpy.defaultProps = {
42-
debounce: 200
43-
};
44-
4541
export default EventSpy;

packages/component/src/ScrollToBottom/AutoHideFollowButton.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const ROOT_STYLE = {
2727
}
2828
};
2929

30-
const AutoHideFollowButton = ({ children, className }) => {
30+
const AutoHideFollowButton = ({ children, className = '' }) => {
3131
const [sticky] = useSticky();
3232
const rootCSS = useStyleToClassName()(ROOT_STYLE);
3333
const scrollToEnd = useScrollToEnd();
@@ -41,11 +41,6 @@ const AutoHideFollowButton = ({ children, className }) => {
4141
);
4242
};
4343

44-
AutoHideFollowButton.defaultProps = {
45-
children: undefined,
46-
className: ''
47-
};
48-
4944
AutoHideFollowButton.propTypes = {
5045
children: PropTypes.any,
5146
className: PropTypes.string

packages/component/src/ScrollToBottom/Composer.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ function isEnd(animateTo, mode) {
5151
}
5252

5353
const Composer = ({
54-
checkInterval,
54+
checkInterval = 100,
5555
children,
56-
debounce,
56+
debounce = 17,
5757
debug: debugFromProp,
58-
initialScrollBehavior,
58+
initialScrollBehavior = 'smooth',
5959
mode,
6060
nonce,
61-
scroller
61+
scroller = DEFAULT_SCROLLER
6262
}) => {
6363
const debug = useMemo(() => createDebug(`<ScrollToBottom>`, { force: debugFromProp }), [debugFromProp]);
6464

@@ -618,17 +618,6 @@ const Composer = ({
618618
);
619619
};
620620

621-
Composer.defaultProps = {
622-
checkInterval: 100,
623-
children: undefined,
624-
debounce: 17,
625-
debug: undefined,
626-
initialScrollBehavior: 'smooth',
627-
mode: undefined,
628-
nonce: undefined,
629-
scroller: DEFAULT_SCROLLER
630-
};
631-
632621
Composer.propTypes = {
633622
checkInterval: PropTypes.number,
634623
children: PropTypes.any,

packages/component/src/ScrollToBottom/Panel.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ const Panel = ({ children, className }) => {
2222
);
2323
};
2424

25-
Panel.defaultProps = {
26-
children: undefined,
27-
className: undefined
28-
};
29-
3025
Panel.propTypes = {
3126
children: PropTypes.any,
3227
className: PropTypes.string

0 commit comments

Comments
 (0)