FaasJS React And Ant Design
Default Workflow
- Start from feature-local files under
features/<feature>/. - Use
@faasjs/ant-designrequest exports in Ant Design apps so request errors and feedback stay consistent. - Use
useFaasfor component-owned requests,faasfor event handlers,Formfaasfor submits, anduseFaasStreamfor streaming. - Avoid native
useEffectby default; use FaasJS React lifecycle helpers for side effects and non-primitive dependencies. - Use
createProxyStatesfor shared state whose data changes must be propagated across independent components or component trees. - For CRUD, compose list, detail, create/update, and delete from shared feature metadata rather than separate one-off flows.
Load These References
- Component and hook rules:
references/guidelines/react.md. - Request flow selection and lifecycle controls:
references/guidelines/react-data-fetching.md. @faasjs/ant-designpage, route, CRUD, and feedback patterns:references/guidelines/ant-design.md.- React request-flow and component tests:
references/guidelines/react-testing.md. - Complete CRUD vertical slice composition:
references/guidelines/crud-patterns.md.
Gotchas
- Import
faas,useFaas,useFaasStream,FaasReactClient,FaasDataWrapper, andwithFaasDatafrom@faasjs/ant-designin Ant Design apps. - Import
createProxyStatesfrom@faasjs/react; create a stable feature-local state channel and export the generateduseXxx,setXxx, andxxxRefhelpers. - Destructure hook returns at the call site; do not keep broad
resultorstatesobjects. - Keep React event handlers inline by default; extract only for reuse or real boundaries.
- For object or array dependencies, use equal memo/effect helpers instead of native dependency arrays.
- Use
hiddenfor controlled field visibility andif(values)for value-dependent visibility; test visibility again when props or relevant values change. - Prefer
useStatesoruseStatesReffor component-local state, andcreateSplittingContextfor provider-scoped shared state; reach forcreateProxyStateswhen data-change notifications must cross components, regardless of where the setter is called.
Validation
- Use
vp test <pattern>for affected component, hook, or request-flow tests. - Use
setMockfor request-layer React tests. - Run
vp check --fixbefore handoff when UI files changed.