Closed beaucollins closed 5 months ago
Love it. I wish we could decorate the actual form context with the refs since we're not enforcing that the keys here match anything in the form, but /shrug. I know you saw some of the other TODOs around typing in here - we originally wrote this without strict tsconfig on, which let us be a little loosey-goosey, and adding types after the fact was tricky since I'm not an expert in TypeScript magic.
fieldRefs
is more accurately represented as aconst
Record
type. Byas const
ing the strict key and value types are captured by the type system.Before, it's an array of objects that get searched through
After, it's a Record of explicit keys and ref values:
We don't need
getFieldRef
anymore, the keys are statically known. And no more iterating just to look up the correct ref.