From 2e8e61309a1010bec3814d3528abe216ed6cbc7f Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Wed, 15 Jan 2025 16:12:54 -0800 Subject: [PATCH] Remove use of default props (#4118) * refactor: replace defaultProps with function parameters in Modal, Statusbar, ChatContainer, and CrossfadeImage components * New commit for Default properties of React components after syncing fork and rebasing * fix: fix linter warning --------- Co-authored-by: swarup --- .DS_Store | Bin 0 -> 10244 bytes package-lock.json | 6 ++++++ .../chat/ChatContainer/ChatContainer.tsx | 9 ++------- .../ui/CrossfadeImage/CrossfadeImage.tsx | 9 ++------- web/components/ui/Modal/Modal.tsx | 10 +++++----- web/components/ui/Statusbar/Statusbar.tsx | 10 ++-------- 6 files changed, 17 insertions(+), 27 deletions(-) create mode 100644 .DS_Store create mode 100644 package-lock.json diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..784451480fdedad6454fceb8fa29825340784234 GIT binary patch literal 10244 zcmZQzU|@7AO)+F(P+(wS;9!8z0z3>@0Z1N%F(jFwA_*Y#7#IW?7%~~s8S-+{4TF>O zp>m_tXb6mkz-S1JhQMeDjE2DA3IRrlb2zvm^e8zR0;3@?8UpYT0F@7*4g!dFfVA-$ z8Xz=Ch=GxT0o(;(WME){X<`KT0~kPZAgv%8q!mPiv@$S)SYR{2S{WFjS{cFJ5Rg6r zuu+WQt_g?_*3Q5PwwZx}5o|L910zH`10&RCMraR(5u%-e5o|jH10zH`*vwI4Gz3ON z05t?aeRp;SJ%$v9REA>Y{(Ei#L?PcH1_lN+6}kB?E=f80Nua@lgV|eI@y50j@VUA7MK- zd1QMn*uj1U`4Vg|Lk2@BLlUy>3=Ffopgu%Wf$Rp+H7MbLq6*;>+^Ue>!@#%zG(gAgMrh&rX$X$nk=r3gI5ys!-em8rxxD;ATiS?Nfy~|sRp>+C@K(f zg`-@ z+Zp)H!10Wt0@)3*+`D0JKr;u~CAd|gxChc`WM{}_NQI^;^w3}^0M#OBDv;gt#1hFp zDCQu$2e&Fz_khEPjUg9Of-~fx#SKH4FarYviafGgUTlWD1x*biKjKn@;ts|OpmfN~ zkjIb@F26w~Lo!1mn4Qm%hwdsBkgM>hMs{P`DYzT)>Oi=dI2|bNX9xhfpPQk8A(f#B z+)gQGC}But$YV%G%gqcOkHGa0R+Y%^R{jomHx6@=|Ri9nG9-Q zq2>(E^`Q0>x*B9Rnz8PI!JO;&YF+&Nm{WIHc!0da-Fh4`}A=`;5i)HBo*?kNg;Btux)RIJT5rfb>aQ#@xP=M@)NgSVGZUE~+4heKQ z6nh}`0w^p-@n{H)h5#f4m?4w`X#C%mfdSY2KSb3iIT`|^AuudMfRV)|*u@DvD39HL zps{w)csjUO4^;;m&1VFS&qMeiC7_{w@Nhg6WKod@$TUU<1_KZc!i)?I-~kFo2FPgs mfK3K~S13Wo6&XhR|Dds3r11enOK!CPk35cm+}a%a{eJ+9w46u) literal 0 HcmV?d00001 diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..ca4f9b39a --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "owncast", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/web/components/chat/ChatContainer/ChatContainer.tsx b/web/components/chat/ChatContainer/ChatContainer.tsx index cd8fab348..72d23dfa0 100644 --- a/web/components/chat/ChatContainer/ChatContainer.tsx +++ b/web/components/chat/ChatContainer/ChatContainer.tsx @@ -79,8 +79,8 @@ export const ChatContainer: FC = ({ usernameToHighlight, chatUserId, isModerator, - showInput, - height, + showInput = true, + height = 'auto', chatAvailable: chatEnabled, desktop, focusInput = true, @@ -377,8 +377,3 @@ export const ChatContainer: FC = ({ ); }; - -ChatContainer.defaultProps = { - showInput: true, - height: 'auto', -}; diff --git a/web/components/ui/CrossfadeImage/CrossfadeImage.tsx b/web/components/ui/CrossfadeImage/CrossfadeImage.tsx index 4a30c6c06..7e3baddb8 100644 --- a/web/components/ui/CrossfadeImage/CrossfadeImage.tsx +++ b/web/components/ui/CrossfadeImage/CrossfadeImage.tsx @@ -21,8 +21,8 @@ export const CrossfadeImage: FC = ({ src = '', width, height, - objectFit = 'fill', - duration = '1s', + objectFit = 'fill', // default value for objectFit + duration = '3s', // default value for duration className, }) => { const spanStyle: React.CSSProperties = useMemo( @@ -70,8 +70,3 @@ export const CrossfadeImage: FC = ({ ); }; - -CrossfadeImage.defaultProps = { - objectFit: 'fill', - duration: '3s', -}; diff --git a/web/components/ui/Modal/Modal.tsx b/web/components/ui/Modal/Modal.tsx index 7f87cc77d..7a920acb8 100644 --- a/web/components/ui/Modal/Modal.tsx +++ b/web/components/ui/Modal/Modal.tsx @@ -18,14 +18,14 @@ export type ModalProps = { export const Modal: FC = ({ title, - url, + url = undefined, open, - handleOk, - handleCancel, - afterClose, + handleOk = undefined, + handleCancel = undefined, + afterClose = undefined, height, width, - children, + children = undefined, }) => { const [loading, setLoading] = useState(!!url); diff --git a/web/components/ui/Statusbar/Statusbar.tsx b/web/components/ui/Statusbar/Statusbar.tsx index 04cf32d7b..13555faae 100644 --- a/web/components/ui/Statusbar/Statusbar.tsx +++ b/web/components/ui/Statusbar/Statusbar.tsx @@ -5,7 +5,6 @@ import classNames from 'classnames'; import styles from './Statusbar.module.scss'; // Lazy loaded components - const EyeFilled = dynamic(() => import('@ant-design/icons/EyeFilled'), { ssr: false, }); @@ -40,8 +39,8 @@ function makeDurationString(lastConnectTime: Date): string { export const Statusbar: FC = ({ online, - lastConnectTime, - lastDisconnectTime, + lastConnectTime = null, + lastDisconnectTime = null, viewerCount, className, }) => { @@ -84,8 +83,3 @@ export const Statusbar: FC = ({ ); }; - -Statusbar.defaultProps = { - lastConnectTime: null, - lastDisconnectTime: null, -};