Skip to content

Remove defaultProps (use default parameters) #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 1 addition & 23 deletions packages/component/src/BasicScrollToBottom.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ const BasicScrollToBottomCore = ({ children, className, followButtonClassName, s
);
};

BasicScrollToBottomCore.defaultProps = {
children: undefined,
className: undefined,
followButtonClassName: undefined,
scrollViewClassName: undefined
};

BasicScrollToBottomCore.propTypes = {
children: PropTypes.any,
className: PropTypes.string,
Expand All @@ -43,7 +36,7 @@ const BasicScrollToBottom = ({
debounce,
debug,
followButtonClassName,
initialScrollBehavior,
initialScrollBehavior = 'smooth',
mode,
nonce,
scroller,
Expand All @@ -70,21 +63,6 @@ const BasicScrollToBottom = ({
</Composer>
);

BasicScrollToBottom.defaultProps = {
checkInterval: undefined,
children: undefined,
className: undefined,
debounce: undefined,
debug: undefined,
followButtonClassName: undefined,
initialScrollBehavior: 'smooth',
mode: undefined,
nonce: undefined,
scroller: undefined,
scrollViewClassName: undefined,
styleOptions: undefined
};

BasicScrollToBottom.propTypes = {
checkInterval: PropTypes.number,
children: PropTypes.any,
Expand Down
6 changes: 1 addition & 5 deletions packages/component/src/EventSpy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useCallback, useLayoutEffect, useMemo, useRef } from 'react';

import debounceFn from './debounce';

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

EventSpy.defaultProps = {
debounce: 200
};

export default EventSpy;
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const ROOT_STYLE = {
}
};

const AutoHideFollowButton = ({ children, className }) => {
const AutoHideFollowButton = ({ children, className = '' }) => {
const [sticky] = useSticky();
const rootCSS = useStyleToClassName()(ROOT_STYLE);
const scrollToEnd = useScrollToEnd();
Expand All @@ -41,11 +41,6 @@ const AutoHideFollowButton = ({ children, className }) => {
);
};

AutoHideFollowButton.defaultProps = {
children: undefined,
className: ''
};

AutoHideFollowButton.propTypes = {
children: PropTypes.any,
className: PropTypes.string
Expand Down
20 changes: 4 additions & 16 deletions packages/component/src/ScrollToBottom/Composer.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ function isEnd(animateTo, mode) {
}

const Composer = ({
checkInterval,
checkInterval = 100,
children,
debounce,
debounce = 17,
debug: debugFromProp,
initialScrollBehavior,
initialScrollBehavior = 'smooth',
mode,
nonce,
scroller,
scroller = DEFAULT_SCROLLER,
styleOptions
}) => {
const debug = useMemo(() => createDebug(`<ScrollToBottom>`, { force: debugFromProp }), [debugFromProp]);
Expand Down Expand Up @@ -609,18 +609,6 @@ const Composer = ({
);
};

Composer.defaultProps = {
checkInterval: 100,
children: undefined,
debounce: 17,
debug: undefined,
initialScrollBehavior: 'smooth',
mode: undefined,
nonce: undefined,
scroller: DEFAULT_SCROLLER,
styleOptions: undefined
};

Composer.propTypes = {
checkInterval: PropTypes.number,
children: PropTypes.any,
Expand Down
5 changes: 0 additions & 5 deletions packages/component/src/ScrollToBottom/Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ const Panel = ({ children, className }) => {
);
};

Panel.defaultProps = {
children: undefined,
className: undefined
};

Panel.propTypes = {
children: PropTypes.any,
className: PropTypes.string
Expand Down