Skip to content

Commit

Permalink
Fix: Render children in MySelect component to display options (#3998)
Browse files Browse the repository at this point in the history
The original example did not render the **children** prop, which resulted in the **select** element not displaying the options passed as children. This PR updates the **MySelect** component to properly handle the **children** prop and render the options inside the dropdown.

### Changes Made
Updated MySelect component to include the children prop inside the select element.
This ensures that the options passed as children (e.g., <option> tags) are correctly displayed in the dropdown list.

### Issue Addressed
Incorrect example in the documentation where options passed to the MySelect component were not being rendered.

### Testing
Verified that the options now render correctly in the MySelect component by testing it with the provided example from the tutorial.

### Additional Notes
This PR only fixes the example in the docs and does not introduce any breaking changes.
  • Loading branch information
rohitKumar38344 authored Oct 9, 2024
1 parent 2618cc4 commit 0e0cf9e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -849,12 +849,13 @@ const MyCheckbox = ({ children, ...props }) => {
);
};

const MySelect = ({ label, ...props }) => {
const MySelect = ({children, label, ...props }) => {
const [field, meta] = useField(props);
return (
<div>
<label htmlFor={props.id || props.name}>{label}</label>
<select {...field} {...props} />
{children}
{meta.touched && meta.error ? (
<div className="error">{meta.error}</div>
) : null}
Expand Down

0 comments on commit 0e0cf9e

Please sign in to comment.