react-component / react-component/field-form

prefixName only part of InternalFormInstance for shouldUpdate callback

Open
#298 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.