APIs to know
The pro-components 2.8.10 props that are most often used wrong: ProTable, forms in a Modal or Drawer, valueType, and valueEnum.
Apps on manh.run run exactly @ant-design/pro-components@2.8.10. This page lists only the parts that are easy to get wrong; the full reference is at procomponents.ant.design .
ProTable
request(params, sort, filter)must return{ data, total, success: true }.paramsholdscurrent,pageSize, and every search field, keyed bydataIndex.params={{ … }}— extra input forrequest; any change reloads the table. UsemanualRequestto wait for the user’s first search.- After a create, update, or delete:
actionRef.current?.reload().reloadAndRest()reloads and goes back to page 1;clearSelected()clears the selected rows. columnsState={{ persistenceKey: "requests", persistenceType: "localStorage" }}remembers hidden and pinned columns per user.search={false}hides the search form;options={false}hides the density, reload, and column settings buttons.dateFormatter="string"sends search dates as strings, not dayjs objects.polling(ms, minimum 2000) for lists that update on their own.- Column flags:
search: false,hideInTable,hideInSearch,hideInForm,hideInDescriptions,copyable,ellipsis,sorter,fixed,search.transform.
Forms
- Field
width:xs104 ·sm216 ·md328 ·lg440 ·xl552 (px). - When
onFinishreturnstrue,ModalForm/DrawerFormcloses; when it returnsfalseor throws, the form stays open. - Fields reset on reopen only when you set
modalProps.destroyOnClose/drawerProps.destroyOnClose. antd v6’sdestroyOnHiddenalone doesn’t reset them (see Forms). submitter={{ searchConfig: { submitText, resetText } }}changes the button text;submitter={false}hides the buttons;rendermoves them elsewhere, for example intoFooterToolbar.ProFormDependency name={[…]}for conditional fields;transformon a field reshapes the submitted value;convertValuedoes the reverse for display.- Use
renderFormItem(2.x).formItemRenderis a v3 name and does nothing here.
valueType
One valueType drives the table cell, the search field, the form field, and the detail item at once. Values available in 2.8.10:
- Text:
text,textarea,password,code,jsonCode - Numbers:
digit,money,percent,progress,second,rate - Dates and times:
date,dateTime,dateWeek,dateMonth,dateQuarter,dateYear,dateRange,dateTimeRange,time,timeRange,fromNow - Choices:
select,treeSelect,checkbox,radio,radioButton,switch,segmented,cascader,color - Images:
avatar,image - Layout (schema forms):
group,formList,formSet,divider,dependency - Table only:
option(action column),index,indexBorder
valueType can be a function of the row, or an object with options:
const columns: ProColumns<Project>[] = [
{ title: "Progress", dataIndex: "pct",
valueType: (r) => ({ type: "progress", status: r.late ? "exception" : "active" }) },
{ title: "Price", dataIndex: "price", valueType: { type: "money", locale: "vi-VN" } },
// …
];valueEnum
valueEnum turns a select column or a status column into colored Badges. status values: Success, Error, Processing, Warning, Default.
const STATUS = {
pending: { text: "Pending", status: "Processing" },
approved: { text: "Approved", status: "Success" },
rejected: { text: "Rejected", status: "Error" },
};Good to know
statusinvalueEnumis capitalized ("Success"), while antdBadge statusis lowercase ("success"). If you share one status map between them, convert between the two, or the colored dots disappear without an error.- Examples on the web may use pro-components v3 prop names. A prop that doesn’t exist in 2.8.10 has no effect, so check it before you use it.
manh/ui
manh/ui puts money, number, date and phone formatting, status colors and an antd theme in one place. It is a frontend (.tsx) module, available in every app with nothing to install. An app that does not import it is not affected.
import { formatMoney, formatDate, formatPhone, statusColor } from "manh/ui";
formatMoney(1234567); // "1.234.567 ₫" (default vi-VN, VND)
formatMoney(1234.5, { currency: "USD", locale: "en-US" }); // "$1,234.50"
formatDate(order.createdAt); // "05/03/2024" (en-US: "Mar 5, 2024")
formatPhone("+84912345678"); // "0912 345 678"
<Tag color={statusColor(order.status)}>{order.status}</Tag>- Locale, currency and the phone country are parameters.
setDefaults({ locale: "en-US", currency: "USD", country: "US" })changes the default for the whole app. Vietnamese and English ship first; other locales still get correct money throughIntl. - Bad input (empty, not a number, an invalid date) returns an empty string and never throws.
statusColorreadspaid,pending,overdue,cancelled… and some Vietnamese labels; an unknown status gets grey.makeConfig({ locale, brand, dark })returnslocaleandthemeto spread ontoConfigProvider.tokensholds the design tokens (status colors, text, surfaces, spacing, radius).- It cannot be used in
app/shared(that folder does not importantd). On the server keep usingmanh/vn.
Next steps
- List pages — ProTable props in a complete page.
- Forms —
DrawerForm,StepsFormand the reset gotcha. - Page recipes — old prop names to replace.