question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[V2] Creatable throws with custom value / label fields

See original GitHub issue

Description:

Go to https://codesandbox.io/s/qj18wmroj and start typing in the select box. Throws TypeError: Cannot read property 'toLowerCase' of undefined.

Cause:

Creatable.js’s https://github.com/JedWatson/react-select/blob/v2.0.0-beta.7/src/Creatable.js#L41-L42 function incorrectly assumes the options object has label and value properties.

Possible Fix

compareOption should use getOptionLabel / getOptionValue before referencing the properties.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:11
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

13reactions
akre54commented, Aug 27, 2018
7reactions
mdzakircommented, Dec 18, 2018

I had this issue.

I found an issue with compareOption function when changes getOptionValue and getOptionLabel to a different (value|label)

Reason why it is throwing this error: compareOption function is trying to first toLowerCase() the option value and label and then compare it with the characters (string) we are typing. So if you are passing anyone of them (value and label) as number or other than string, it will throw an error.

Here is what I did & it worked for me.

And hope it works for everyone here as well. 😄

1. Mapped the array before hand:

let states = statesArray.map(m => {
      return {
        value: m.id.toString(),
        label: m.stateName
      }
    });
  1. Passed the mapped states to Creatable Component
<Creatable
            className="basic-single"
            classNamePrefix="select"
            name="states"
            options={states}
            isMulti
          />
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error thrown when the Custom Label is set to Protected ...
1. Create Custom Label (Setup-> Create-> Custom Labels-> [New Custom Label]). Make sure the 'Protected Component' is checked.
Read more >
Flow: How to update a record using a custom label and a ...
Step 1: First step is to create a custom label. We will assign the value “a0d1v00000m0GtlAAE”, which is the record id for the...
Read more >
Update Date field with the value of custom label in Process ...
It won't work for DATE($Label.NYResident_ExpDate). I have used DATEVALUE function like shown below. DATEVALUE($Label.NYResident_ExpDate).
Read more >
Dynamically populate a select field's choices - ACF
This tutorial will cover how to take a value saved to the options page and ... field is called my_select_values ) and use...
Read more >
Custom label 0-4 [custom_label_0-4] (Collections)
Custom labels allow you to create specific filters to use in your collections. ... up to 1,000 unique values account-wide for each custom...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found