Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/framework/react/guides/ssr.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export const ClientComp = () => {
return (
<div>
<input
name="age"
name="age" // must explicitly set the name attribute for the POST request
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to use name={field.name} instead of a new string? Or is there something users should know about what names to choose for the JSX elements?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're absolutely right (I feel like an AI assistant with that response 😄)!

Since we have access to the field object on the render prop, we should definitely use name={field.name} rather than hard-coding the name attribute. That's what I'm doing in my own project in the component that uses useFieldContext, but I forgot we have access to the field object here as well. Good catch!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, then! Could you check the whole file for the name prop? Once that's committed, I'll merge. The comment is fine for just the first instance of it imo.

type="number"
value={field.state.value}
onChange={(e) => field.handleChange(e.target.valueAsNumber)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const ClientComp = () => {
return (
<div>
<input
name="age"
name="age" // must explicitly set the name attribute for the POST request
type="number"
value={field.state.value}
onChange={(e) => field.handleChange(e.target.valueAsNumber)}
Expand Down