Skip to content
Discussion options

You must be logged in to vote

When calling <field.YourComponent />, it may seem like it has information about field, but it actually does not. It's the same as if you had called <YourComponent />. The benefit of having the field autocomplete it for you is precisely that, autocompletion.

There's a draft PR searching for a good solution for this (likely a branded component) in #1606

As for making it restricted with the current system, you have to implement that yourself. Luckily, that's fairly straightforward:

interface YourComponentProps {
  field: {
    state: {
       // the field must have this type, we don't care about the rest
       value: number
    }
  }
}

// You don't actually need to use the field prop passed

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gensmusic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants