fix accessing array field type by path
bug
The Field component seems to show type errors when used with an Array field that is not an object - for example:
```
const TestComponent = () => {
const [form, { Form, Field }] = createForm<{ values: number[] }>({
initialValues: { values: [1, 2, 3] },
});
return (
<Form onSubmit={() => {}}>
<Field name="values.0" type="number">
{(field, props) => (
<input type="number" {...props} value={field.value} />
)}
</Field>
</Form>
);
};
```
Will show the errors
- on the "type" prop - "Type 'string' is not assignable to type 'undefined'."
- the type of "field.value" will be "undefined"
This PR updates the PathValue helper to allow looking up a value by array index
合并状态:未合并 2 条评论