React-select: Ability to customise "Create Option for {label}" text in Select-Createable (Get it from Props)

Created on 4 Apr 2018  路  7Comments  路  Source: JedWatson/react-select

It's a feature request. React-Select is already a great library and this small feature request will remove one hard coding from it.

In Select-Createable , if we are creating a new option for a drop-down named "Stores", then instead of showing 'Create option for', we can show 'Create new Store {label}', which will make more sense

So, we should provide have some ability to provide this text as props, so user can customize it.

Pull request for the same #2492

Most helpful comment

// V2
<Select
  formatCreateLabel={userInput => `Search for ${userInput}`}
/>

Please see the docs and in the future please don't file GitHub issues to ask questions. Use Stack Overflow with a #react-select tag

All 7 comments

This is available as promptTextCreator property.

Maybe I am just tired but do I understand correctly that promptTextCreator in v1 and formatCreateLabel in v2 should let us change the default Create "{<Users Input>}" to for example Search "{<Users Input>}" @jossmac ?

If this is true how should we pass this to the promptTextCreator? This does not work:
promptTextCreator={() =>Search}

Ty for a awesome library!

@t0mdicks0n are you asking about v1 or v2?

// V2
<Select
  formatCreateLabel={userInput => `Search for ${userInput}`}
/>

Please see the docs and in the future please don't file GitHub issues to ask questions. Use Stack Overflow with a #react-select tag

There we go! Ty for helping out.

Will do!

@jossmac how we do that for v1? ..formatCreateLabel={userInput => Search for ${userInput}} doesn't work in v1.

@lausellduane see my comment, which references the promptTextCreator function from the v1 docs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mjuopperi picture mjuopperi  路  3Comments

pablote picture pablote  路  3Comments

mbonaci picture mbonaci  路  3Comments

MalcolmDwyer picture MalcolmDwyer  路  3Comments

MindRave picture MindRave  路  3Comments