Skip to content

Commit

Permalink
fix(components): remove deprecated defaultProps component option (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
sawa-ko authored Jun 29, 2023
1 parent b7fa614 commit da6fe51
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
6 changes: 2 additions & 4 deletions src/Case.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import type { ComponentWithConditionPropsWithFunctionChildren } from './types';
* inside the parent `<Switch />` it will be the only rendered.
* @param props The props to pass down to the `<Case />` component
*/
export const Case: FC<ComponentWithConditionPropsWithFunctionChildren> = (props) => render(props);

Case.defaultProps = {
children: null
export const Case: FC<ComponentWithConditionPropsWithFunctionChildren> = ({ children = null }) => {
return render({ children });
};
6 changes: 2 additions & 4 deletions src/Default.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import type { FCWithImplicitChildren } from './types';
* the first `<Default />` will be the only one rendered.
* @param props The props to pass down to the `<Default />` component
*/
export const Default: FCWithImplicitChildren = (props) => render(props);

Default.defaultProps = {
children: null
export const Default: FCWithImplicitChildren = ({ children = null }) => {
return render({ children });
};
6 changes: 1 addition & 5 deletions src/Unless.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ import type { ComponentWithConditionPropsWithFunctionChildren } from './types';
*
* @param __namedParameters The props to pass down to the `<IF />` component, see {@link ComponentWithConditionProps}
*/
export const Unless: FC<ComponentWithConditionPropsWithFunctionChildren> = ({ condition, children }) => {
export const Unless: FC<ComponentWithConditionPropsWithFunctionChildren> = ({ condition, children = null }) => {
const conditionResult = Boolean(getConditionResult(condition));

return !conditionResult && children ? render({ children }) : null;
};

Unless.defaultProps = {
children: null
};
6 changes: 1 addition & 5 deletions src/When.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ import type { ComponentWithConditionPropsWithFunctionChildren } from './types';
*
* @param __namedParameters The props to pass down to the `<IF />` component, see {@link ComponentWithConditionProps}
*/
export const When: FC<ComponentWithConditionPropsWithFunctionChildren> = ({ condition, children }) => {
export const When: FC<ComponentWithConditionPropsWithFunctionChildren> = ({ condition, children = null }) => {
const conditionResult = Boolean(getConditionResult(condition));

return conditionResult && children ? render({ children }) : null;
};

When.defaultProps = {
children: null
};

0 comments on commit da6fe51

Please sign in to comment.