From da6fe51ceadaba1b9af3fd3d2b35f4aaf278b77e Mon Sep 17 00:00:00 2001
From: Sawako <56084970+sawa-ko@users.noreply.github.com>
Date: Thu, 29 Jun 2023 12:22:56 -0600
Subject: [PATCH] fix(components): remove deprecated defaultProps component
option (#279)
---
src/Case.tsx | 6 ++----
src/Default.tsx | 6 ++----
src/Unless.tsx | 6 +-----
src/When.tsx | 6 +-----
4 files changed, 6 insertions(+), 18 deletions(-)
diff --git a/src/Case.tsx b/src/Case.tsx
index 0646e7e8..80b6c20a 100644
--- a/src/Case.tsx
+++ b/src/Case.tsx
@@ -7,8 +7,6 @@ import type { ComponentWithConditionPropsWithFunctionChildren } from './types';
* inside the parent `` it will be the only rendered.
* @param props The props to pass down to the `` component
*/
-export const Case: FC = (props) => render(props);
-
-Case.defaultProps = {
- children: null
+export const Case: FC = ({ children = null }) => {
+ return render({ children });
};
diff --git a/src/Default.tsx b/src/Default.tsx
index 71503c71..a773d803 100644
--- a/src/Default.tsx
+++ b/src/Default.tsx
@@ -6,8 +6,6 @@ import type { FCWithImplicitChildren } from './types';
* the first `` will be the only one rendered.
* @param props The props to pass down to the `` component
*/
-export const Default: FCWithImplicitChildren = (props) => render(props);
-
-Default.defaultProps = {
- children: null
+export const Default: FCWithImplicitChildren = ({ children = null }) => {
+ return render({ children });
};
diff --git a/src/Unless.tsx b/src/Unless.tsx
index 8c756f69..b3e16b3c 100644
--- a/src/Unless.tsx
+++ b/src/Unless.tsx
@@ -17,12 +17,8 @@ import type { ComponentWithConditionPropsWithFunctionChildren } from './types';
*
* @param __namedParameters The props to pass down to the `` component, see {@link ComponentWithConditionProps}
*/
-export const Unless: FC = ({ condition, children }) => {
+export const Unless: FC = ({ condition, children = null }) => {
const conditionResult = Boolean(getConditionResult(condition));
return !conditionResult && children ? render({ children }) : null;
};
-
-Unless.defaultProps = {
- children: null
-};
diff --git a/src/When.tsx b/src/When.tsx
index 0db2236d..10ed97bd 100644
--- a/src/When.tsx
+++ b/src/When.tsx
@@ -17,12 +17,8 @@ import type { ComponentWithConditionPropsWithFunctionChildren } from './types';
*
* @param __namedParameters The props to pass down to the `` component, see {@link ComponentWithConditionProps}
*/
-export const When: FC = ({ condition, children }) => {
+export const When: FC = ({ condition, children = null }) => {
const conditionResult = Boolean(getConditionResult(condition));
return conditionResult && children ? render({ children }) : null;
};
-
-When.defaultProps = {
- children: null
-};