react-component / react-component/field-form
prefixName only part of InternalFormInstance for shouldUpdate callback
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1k
- Forks
- 286
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 1
Description
Hi,
in antd I'd need to use prefixName that is passed to the child form field, but it seems to be only for internal use. Is there an other way to get the prefix name without using this property or is is save to use?
prefixName?: InternalNamePath;
https://github.com/ant-design/ant-design/issues/30529
<Form.Field shouldUpdate >
{(form) => {
// this is then undefined according to type definition but holds the item path to access the element!
console.log(form.prefixName)
// type should be from https://github.com/react-component/field-form/blob/e118381c2102b36c4ffe7e17a6415df091e772b7/src/interface.ts#L233
return (
<Form.Field name="fun" hidden={form.getFieldValue([...form.prefixName, 'other'])}>
<Input />
</Form.Field>
)
}}
</Form.Field>
(here the real world use case: https://github.com/ohmyform/ui/blob/logic/components/form/admin/types/slider.type.tsx)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/interface.ts around the linked InternalFormInstance definition and compare it with the shouldUpdate callback usage shown in the issue. Review the linked Ant Design issue and real-world example to determine the intended public shape; done means prefixName usage in the callback is accurately represented by the field-form types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100