Skip to content

Commit e8dc45d

Browse files
author
Hardik_B
committed
[UPDATED] build to exclude test files
1 parent 645c075 commit e8dc45d

4 files changed

Lines changed: 14 additions & 14 deletions

File tree

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dx-kit/react-conditional-match",
3-
"version": "2.2.2",
3+
"version": "2.2.3",
44
"description": "A flexible and reusable React component for conditionally rendering child elements. The component supports options for handling multiple matching children and custom fallbacks, and is lightweight and easy to use. This component can help simplify complex rendering logic in your React application and remove the need for ternary statements and if else blocks.",
55
"main": "./dist/index.esm.js",
66
"module": "./dist/index.cjs.js",
@@ -47,10 +47,10 @@
4747
"README.md"
4848
],
4949
"dependencies": {
50-
"@types/react": "^18.0.28",
51-
"@types/react-dom": "^18.0.11",
5250
"react": "^18.2.0",
53-
"react-dom": "^18.2.0"
51+
"react-dom": "^18.2.0",
52+
"@types/react": "^18.0.28",
53+
"@types/react-dom": "^18.0.11"
5454
},
5555
"devDependencies": {
5656
"@testing-library/jest-dom": "^5.16.5",

src/components/ConditionalMatch/ConditionalMatch.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import { Children, Fragment, ReactNode, useMemo } from "react";
1+
import React from "react";
22

33
import { Render } from "./components/Render";
44

55
export interface ConditionalMatchProps {
66
/** The fallback element to render if no children match the condition */
7-
fallback: ReactNode;
7+
fallback: React.ReactNode;
88
/** The children to search for a matching condition */
99
children?: JSX.Element | JSX.Element[] | null;
1010
/** Whether to render all matching children (if true) or only the first matching child (if false) */
1111
multiMatch?: boolean;
1212
}
1313

1414
const ConditionalMatch = ({ fallback, children = null, multiMatch = false }: ConditionalMatchProps): JSX.Element => {
15-
const matchedChildren = useMemo(() => {
15+
const matchedChildren = React.useMemo(() => {
1616
const childrenToRender: JSX.Element[] = [];
1717

18-
Children.forEach(children, (child) => {
18+
React.Children.forEach(children, (child) => {
1919
if (child?.type !== Render) {
2020
return;
2121
}
@@ -33,10 +33,10 @@ const ConditionalMatch = ({ fallback, children = null, multiMatch = false }: Con
3333
}, [children, multiMatch]);
3434

3535
if (matchedChildren?.length) {
36-
return <Fragment>{matchedChildren}</Fragment>;
36+
return <React.Fragment>{matchedChildren}</React.Fragment>;
3737
}
3838

39-
return <Fragment>{fallback}</Fragment>;
39+
return <React.Fragment>{fallback}</React.Fragment>;
4040
};
4141

4242
const ConditionalMatchCompound = Object.assign(ConditionalMatch, {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { Fragment, ReactNode } from "react";
1+
import React from "react";
22

33
type RenderProps<T> = {
44
/** The condition to determine whether to render the children */
55
when: T | undefined | null | boolean;
66
/** The children to render if the condition is true */
7-
children: ReactNode;
7+
children: React.ReactNode;
88
};
99

1010
function Render<T>({ children, when }: RenderProps<T>): JSX.Element | null {
1111
if (!when) {
1212
return null;
1313
}
1414

15-
return <Fragment>{children}</Fragment>;
15+
return <React.Fragment>{children}</React.Fragment>;
1616
}
1717

1818
export { Render };

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"include": ["src"],
3-
"exclude": ["dist", "node_modules", "build.js"],
3+
"exclude": ["dist", "node_modules", "build.js", "src/**/*.test.{js,ts,jsx,tsx}"],
44
"compilerOptions": {
55
"module": "esnext",
66
"lib": ["dom", "esnext"],

0 commit comments

Comments
 (0)