JedWatson / JedWatson/react-select

OptionType doesn't describe what it accepts

Open
#5,894 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

issue/bug-unconfirmed
Dominant language
TypeScript
Stars
28k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

This is more of a documentation bug than anything else, although maybe there's a bug in here somewhere. This shows up in the "OptionType":

type OptionType = { [string]: any }

Which is a pojo, anything goes. And while you can provide any object, I found there was some weirdness.

When I used the select with an array of objects looking like {id, name}, after I selected an option every option turned blue... Once I refreshed the page, it would go back to normal. I'm using HMR so needed to refresh the page a lot.

It look me a while to figure out how to keep the menu open, then that the applied classes on my blue entries correspond to something being selected -- so selecting one item selected all of them? Weird.

Looking through some of the examples that people have used, I started passing {label, value} in addition to custom properties and sure enough, once value was present, the issue went away.

Seems to me the type for OptionType should explicitly list value if it's required for functionality.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the OptionType definition and reviewing the select examples that pass objects with label and value. Confirm whether value is required for correct selection behavior, then update the type documentation or definition to describe that requirement and verify the reported object-selection behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.