react-component / react-component/select
Can't create a Select component with a Object value
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 938
- Forks
- 482
- Avg merge
- 15h 8m
- Merged PRs (30d)
- 2
Description
I'm trying to create a Select component with a object value.
{
label: `My String`,
value: { CuteCharm: true },
}
This results in a runtime error because value is rendered here: https://github.com/react-component/select/blob/48e24574fdf6a7b68589631e32d69d8dc629c974/src/OptionList.tsx#L309C9-L309C16
Expected behaviour: value can be an object, and it is not rendered (only label is rendered).
Proposed solution: Replace {value} by {typeof value === 'object' ? value.toString() : value}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/OptionList.tsx at the rendering code linked from the issue and reproduce the runtime error with an option whose value is an object. Confirm that the label remains the rendered text while object-valued options no longer cause the error, then verify the relevant Select behavior with the existing test suite.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100