question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type Definition wrong for Child Renderer of Form.Item

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

<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>

What is expected?

the type for the passed form should include the prefixName property

What is actually happening?

the prefixName property is accessible but not defined in the type

Environment Info
antd 4.15.3
React 17.0.2
System OSX
Browser Chrome

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
zombieJcommented, May 28, 2021
const { xxx } = React.useContext(FieldContext);
0reactions
wodkacommented, Jan 2, 2022

by now it is no longer possible to get the context as in https://github.com/ant-design/ant-design/issues/30529#issuecomment-850272255.

Is there any other way to do this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

React: how to use child FormItem components without getting ...
I have tried to remove the <Form> </Form> tags in my child component, but then it is a compile error. Is there a...
Read more >
NForm: Nested Forms: Child Forms - GitHub Pages
In this tutorial we use the material renderer. The material renderer does not render child forms, instead it renders an edit button which...
Read more >
lightning-record-edit-form - Salesforce Developers
Use the lightning-record-edit-form component to create a form that's used to add a Salesforce record or update fields in an existing record on...
Read more >
The Button element - HTML: HyperText Markup Language
If the button is a submit button, this Boolean attribute specifies that the form is not to be validated when it is submitted....
Read more >
Typechecking With PropTypes - React
With PropTypes.element you can specify that only a single child can be passed to a component as children. import PropTypes from 'prop-types'; class...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found