Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve use select hook #681

Merged
merged 3 commits into from
Mar 14, 2024
Merged

feat: improve use select hook #681

merged 3 commits into from
Mar 14, 2024

Conversation

hamed-musallam
Copy link
Contributor

@hamed-musallam hamed-musallam commented Mar 13, 2024

Improve the useSelect hook :

  • It accepts a defaultSelectedItem property.
  • You can specify which object serves as the label in two ways:
    • Using the itemTextKey property, which accepts only keys where the value type is a string.
    • Using the getItemText function, which takes an item as a parameter and returns a string.

- It accepts a 'defaultSelectedItem' property.
- You can specify which object serves as the label in two ways:
    - Using the 'itemLabelKey' property, which accepts only keys where the value type is string.
    - Using the 'itemLabelMap' function, which takes an item as a parameter and returns a string.
Copy link

cloudflare-workers-and-pages bot commented Mar 13, 2024

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: eb4623e
Status: ✅  Deploy successful!
Preview URL: https://8560cf9b.react-science.pages.dev
Branch Preview URL: https://improve-use-select-hook.react-science.pages.dev

View logs

@hamed-musallam
Copy link
Contributor Author

@stropitek

could you take a look at this PR, Now the useSelect hook

  • It accepts a defaultSelectedItem property.
  • You can specify which object serves as the label in two ways:
    • Using the itemLabelKey property, which accepts only keys where the value type is a string.
    • Using the itemLabelMap function, which takes an item as a parameter and returns a string.

@hamed-musallam hamed-musallam linked an issue Mar 13, 2024 that may be closed by this pull request
src/components/hooks/useSelect.tsx Outdated Show resolved Hide resolved
src/components/hooks/useSelect.tsx Outdated Show resolved Hide resolved
 - rename 'itemLabelKey' to 'itemTextKey'
 - rename 'itemLabelMap' to 'getItemText'
@stropitek stropitek merged commit c9125c8 into main Mar 14, 2024
12 checks passed
@stropitek stropitek deleted the improve-use-select-hook branch March 14, 2024 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

set a default selected item for the select component
2 participants