Skip to content

Commit 606dc8c

Browse files
authored
docs(unstable): add a description of the correct use of name prop (#307)
1 parent 81006c8 commit 606dc8c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/lib/unstable/core/SchemaRenderer/SchemaRenderer.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,28 @@ export interface SchemaRendererProps {
1010
config: SchemaRendererConfig;
1111
errorMessages?: ErrorMessages;
1212
mode: SchemaRendererMode;
13+
/**
14+
* The `name` prop must be a non-empty string.
15+
*
16+
* In `final-form` and `react-final-form`, the `name` is used as a key to register
17+
* the field within the form. If you pass an empty string (`name=""`), the field will
18+
* not be registered, its value will not be tracked, and validation will not work.
19+
*
20+
* This can lead to:
21+
* - the field being missing from the form `values`;
22+
* - the `validate` function not being called;
23+
* - no error or touched state updates;
24+
* - inconsistent or broken form behavior.
25+
*
26+
* Always provide a unique, non-empty string for the field name.
27+
*
28+
* @example
29+
* // Incorrect
30+
* <SchemaRenderer name="" {...pros} />
31+
*
32+
* // Correct
33+
* <SchemaRenderer name="params" {...pros} />
34+
*/
1335
name: string;
1436
schema: JsonSchema;
1537
}

0 commit comments

Comments
 (0)