Skip to content

Commit

Permalink
demo: update demo type React.ReactNode => React.PropsWithChildren
Browse files Browse the repository at this point in the history
  • Loading branch information
li-jia-nan committed May 5, 2024
1 parent 313d534 commit 7b9dbf1
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion components/button/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('Button', () => {
});

it('renders Chinese characters correctly in HOC', () => {
const Text = ({ children }: { children: React.ReactNode }) => <span>{children}</span>;
const Text: React.FC<React.PropsWithChildren> = ({ children }) => <span>{children}</span>;
const { container, rerender } = render(
<Button>
<Text>按钮</Text>
Expand Down
6 changes: 4 additions & 2 deletions components/form/demo/form-item-path.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ const MyFormItemContext = React.createContext<(string | number)[]>([]);

interface MyFormItemGroupProps {
prefix: string | number | (string | number)[];
children: React.ReactNode;
}

function toArr(str: string | number | (string | number)[]): (string | number)[] {
return Array.isArray(str) ? str : [str];
}

const MyFormItemGroup = ({ prefix, children }: MyFormItemGroupProps) => {
const MyFormItemGroup: React.FC<React.PropsWithChildren<MyFormItemGroupProps>> = ({
prefix,
children,
}) => {
const prefixPath = React.useContext(MyFormItemContext);
const concatPath = React.useMemo(() => [...prefixPath, ...toArr(prefix)], [prefixPath, prefix]);

Expand Down
2 changes: 1 addition & 1 deletion components/grid/demo/flex-align.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Col, Divider, Row } from 'antd';

const DemoBox: React.FC<{ children: React.ReactNode; value: number }> = (props) => (
const DemoBox: React.FC<React.PropsWithChildren<{ value: number }>> = (props) => (
<p className={`height-${props.value}`}>{props.children}</p>
);

Expand Down
3 changes: 1 addition & 2 deletions components/table/demo/edit-cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ const EditableRow: React.FC<EditableRowProps> = ({ index, ...props }) => {
interface EditableCellProps {
title: React.ReactNode;
editable: boolean;
children: React.ReactNode;
dataIndex: keyof Item;
record: Item;
handleSave: (record: Item) => void;
}

const EditableCell: React.FC<EditableCellProps> = ({
const EditableCell: React.FC<React.PropsWithChildren<EditableCellProps>> = ({
title,
editable,
children,
Expand Down
3 changes: 1 addition & 2 deletions components/table/demo/edit-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ interface EditableCellProps extends React.HTMLAttributes<HTMLElement> {
inputType: 'number' | 'text';
record: Item;
index: number;
children: React.ReactNode;
}

const EditableCell: React.FC<EditableCellProps> = ({
const EditableCell: React.FC<React.PropsWithChildren<EditableCellProps>> = ({
editing,
dataIndex,
title,
Expand Down

0 comments on commit 7b9dbf1

Please sign in to comment.