Overview of @react-vant/icons
main@react-vant/icons is a library of SVG icons designed specifically for use with the react-vant component library.repository·main·Indexed 23 days ago
https://github.com/3lang3/react-vantA mobile component library for React based on the Vant design system, providing over 70 high-quality components optimized for mobile web scenarios. Version 0.0.1-rc.0 includes components such as ActionBar, ActionSheet, Area, and Badge, along with a dedicated SVG icon library provided via the @react-vant/icons package.
@react-vant/icons is a library of SVG icons designed specifically for use with the react-vant component library.react-vant is a mobile UI component library for React, inspired by Vant. It is designed for high performance and mobile-first scenarios.
The Slider component is a sliding input bar used to select a value within a given range. It supports single value selection and range selection (dual sliders).
import { useState } from 'react';
import { Slider } from 'react-vant';
export default () => {
const [value, setValue] = useState(10);
return <Slider value={value} onChange={setValue} />;
};The Space component is used to set spacing between components to prevent them from being tightly packed together and to maintain a consistent layout. It supports both horizontal and vertical directions, alignment on both axes, and automatic wrapping.
import { Space } from 'react-vant';The repository is organized into several key directories:
src: Contains the component source code. Each component resides in its own folder within src/components.docs: Contains the source code for the documentation website.dist: Contains the built component artifacts.docs-dist: Contains the built documentation artifacts.typings: Contains type definitions.When a Form.Item has a name property, the Form component takes over data synchronization. It automatically injects value (or the property specified by valuePropName) and onChange (or the property specified by trigger) into its children.
Requirements for children:
ReactElement.value and onChange props.Common Mistakes to Avoid:
Form.Item that has a name.div, as the div will receive the value and onChange props instead of the input component.useState to manually control the value or onChange of a component inside a Form.Item. Use initialValues on the Form for defaults and form.setFieldsValue for dynamic updates.// Correct
<Form.Item name="foo">
<Input />
</Form.Item>
// Incorrect: Multiple children
<Form.Item name="foo">
<Input />
<div>hello</div>
</Form.Item>
// Incorrect: Wrapper div prevents props from reaching Input
<Form.Item name="foo">
<div>
<Input />
</div>
</Form.Item>
// Incorrect: Manual state management
<Form.Item name="foo">
<Input
value={myInputValue}
onChange={(v) => setMyInputValue(v)}
/>
</Form.Item>The areaList prop expects an object containing three keys: province_list, city_list, and county_list.
Each list is an object where the key is a 6-digit area code (e.g., 110000 for Beijing) and the value is the name of the region. The area code follows a pattern where the first two digits represent the province, the middle two the city, and the last two the county/district.
const areaList = {
province_list: {
110000: '北京市',
120000: '天津市',
},
city_list: {
110100: '北京市',
120100: '天津市',
},
county_list: {
110101: '东城区',
110102: '西城区',
// ....
},
};The useFormSmart hook simplifies managing Form components by providing data synchronization capabilities. It allows you to automatically update form values when external data changes.
By default, when the value option is provided, the hook sets the form values once. Subsequent changes to value will not re-trigger the form update (similar to initialValues in a standard Form), but it does include empty value detection.
If you need the form to update every time the external value changes, set the sync option to true. This is useful for scenarios where the source data is frequently refreshed or updated.
To use it, pass the returned ref to the Form component.
To react to changes in specific fields (e.g., showing/hiding fields based on a selection), use one of these two methods:
Use Form.Subscribe to wrap a section of your UI that needs to re-render when specific fields change. It provides a render function with changedValues and the form instance.
Use the Form.useWatch hook to watch a specific field and trigger a re-render of the component where the hook is called.
For more complex logic, use the shouldUpdate prop on Form.Item. This allows you to manually control when a specific field item re-renders based on the current form state.
Dialog component declaratively in your JSX instead of the function call method. This allows the dialog to participate in the React component lifecycle correctly.accordion prop. In this mode, initExpanded must be a single string or number rather than an array.checked prop to control the component state, clicking the icon will not automatically change the state. Instead, you must handle the change in the onChange callback and manually update the state variable passed to checked.