Skip to content

fix: fixed Modal.Form ts problems #350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: issuse ts name
  • Loading branch information
Zaoei committed Jun 5, 2023
commit ed14e043b6a1d85e11a5fa32f0ca36b35635222c
14 changes: 7 additions & 7 deletions src/modal/demos/advance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import React, { useState } from 'react';
import { Button, Form, Input, InputNumber, Table } from 'antd';
import { Modal } from 'dt-react-component';

interface FormData {
interface FormValue {
name: string;
age: number;
address: string;
}

interface Data extends FormData {
interface TableData extends FormValue {
key: string;
}

const data: Data[] = [
const data: TableData[] = [
{
key: '1',
name: 'UED',
Expand All @@ -27,7 +27,7 @@ const data: Data[] = [
},
];

const ModalForm = Modal.Form<FormData>((_props) => {
const ModalForm = Modal.Form<FormValue>((_props) => {
return (
<>
<Form.Item label="name" name={'name'}>
Expand All @@ -46,7 +46,7 @@ const ModalForm = Modal.Form<FormData>((_props) => {
export default () => {
const [visible, setVisible] = useState(false);
const [index, setIndex] = useState<number>(0);
const [dataSource, setDataSource] = useState<Data[]>(data);
const [dataSource, setDataSource] = useState<TableData[]>(data);

const columns = [
{
Expand All @@ -68,7 +68,7 @@ export default () => {
title: '操作',
dataIndex: 'operate',
key: 'operate',
render: (_: void, record: Data, index: number) => {
render: (_: void, _record: TableData, index: number) => {
return (
<Button
onClick={() => {
Expand All @@ -84,7 +84,7 @@ export default () => {
},
];

const onSubmit = (values: FormData) => {
const onSubmit = (values: FormValue) => {
dataSource.splice(index, 0, { ...values, key: new Date() + '' });
setDataSource([...dataSource]);

Expand Down
4 changes: 2 additions & 2 deletions src/modal/demos/basics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import React, { useState } from 'react';
import { Button, Form, Input } from 'antd';
import { Modal } from 'dt-react-component';

interface FormData {
interface FormValue {
username: string;
}

const ModalForm = Modal.Form<FormData>((_props) => {
const ModalForm = Modal.Form<FormValue>((_props) => {
return (
<Form.Item label="username" name={'username'} rules={[{ max: 10 }]}>
<Input />
Expand Down