Skip to Content

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 }. params holds current, pageSize, and every search field, keyed by dataIndex.
  • params={{ … }} — extra input for request; any change reloads the table. Use manualRequest to 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: xs 104 · sm 216 · md 328 · lg 440 · xl 552 (px).
  • When onFinish returns true, ModalForm / DrawerForm closes; when it returns false or throws, the form stays open.
  • Fields reset on reopen only when you set modalProps.destroyOnClose / drawerProps.destroyOnClose. antd v6’s destroyOnHidden alone doesn’t reset them (see Forms).
  • submitter={{ searchConfig: { submitText, resetText } }} changes the button text; submitter={false} hides the buttons; render moves them elsewhere, for example into FooterToolbar.
  • ProFormDependency name={[…]} for conditional fields; transform on a field reshapes the submitted value; convertValue does the reverse for display.
  • Use renderFormItem (2.x). formItemRender is 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:

app/projects/page.tsx
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.

app/requests/page.tsx
const STATUS = { pending: { text: "Pending", status: "Processing" }, approved: { text: "Approved", status: "Success" }, rejected: { text: "Rejected", status: "Error" }, };

Good to know

  • status in valueEnum is capitalized ("Success"), while antd Badge status is 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.

app/orders/page.tsx
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 through Intl.
  • Bad input (empty, not a number, an invalid date) returns an empty string and never throws.
  • statusColor reads paid, pending, overdue, cancelled… and some Vietnamese labels; an unknown status gets grey.
  • makeConfig({ locale, brand, dark }) returns locale and theme to spread onto ConfigProvider. tokens holds the design tokens (status colors, text, surfaces, spacing, radius).
  • It cannot be used in app/shared (that folder does not import antd). On the server keep using manh/vn.

Next steps

  • List pages — ProTable props in a complete page.
  • Forms — DrawerForm, StepsForm and the reset gotcha.
  • Page recipes — old prop names to replace.
Last updated