onCreateOption is not called, fails at `valueArray[valueArray.length - 1] === newOption`
See original GitHub issueGetting a weird bug at this line.
It seems that the ===
comparison fails on this line.
valueArray[valueArray.length - 1] === newOption
I put debugger breakpoint and inspected the values. Please see the console output.
> valueArray[valueArray.length - 1] === newOption
false
> newOption === newValue
false
> newOption
{label: "Create "sd"", value: "sd", __isNew__: true}
> newValue
{label: "Create "sd"", value: "sd", __isNew__: true}
> valueArray
[{…}]0: {label: "Create "sd"", value: "sd", __isNew__: true}length: 1__proto__: Array(0)
> valueArray.length
1
It looks like the newOption
and newValue
have the same content by they fail when compared using ===
operator. As the result the onCreateOption
is not called.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:13
- Comments:14 (6 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For anyone struggling with this in the interim, you can use the
getNewOptionData
prop to bust the equality check and properly pass through toonCreateOption
.Ex:
@gwyneplaine Please check out the fix and tell me what you think. I’ve ran the tests and did some manual testing on the docs page - everything seems to be fine. I’d be happy to add a test, but I’ll need a little guidance.