newOptionCreator
See original GitHub issueI cannot for the life of me figure out how to make newOptionCreator
work.
This is what I have so far:
const ContactSelect = React.createClass({
handleChange(input) {
this.props.onContactChange(input.value);
},
onNewOption(newOption) {
return { value: newOption.label, label: newOption.label };
},
render() {
return (
<Creatable
name="contact-select"
value={this.props.contact}
resetValue={{ value: '' }}
placeholder="Choose a contact (optional)..."
options={this.props.contactOptions}
onChange={this.handleChange}
newOptionCreator={this.onNewOption}
/>
);
},
});
The new option does not get shown or selected. What am I missing here?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Using newOptionCreator prop with Creatable only allows ...
I'm using the newOptionCreator prop to add a property to the newly created option before saving the data to an endpoint.
Read more >with redux-form and react-select.creatable why does a blur ...
summary: i'm using react-select.creatable as an autocomplete component for an email dropdown. selecting an email sets the client on the invoice ...
Read more >react-select-legacy
newOptionCreator, function, Factory to create new option. Expected signature: ({ label: string, labelKey: string, valueKey: string }): ...
Read more >src/types/react-select/index.d.ts · 唐嘉勇/bricks
newOptionCreator ?: NewOptionCreatorHandler<TValue>;. /**. * Creates prompt/placeholder for option text. */. promptTextCreator?: PromptTextCreatorHandler;.
Read more >api documentation for react-select (v0.9.1)
newOptionCreator (); function react-select.propTypes.noResultsText (); function react-select.propTypes.onBlur (); function react-select.propTypes.
Read more >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
This is how it looks in the source, you might be missing the class?
https://github.com/JedWatson/react-select/blob/master/src/Creatable.js#L234
@Geczy I’m so very sorry for the delay in getting back to you.
onContactChange()
sets state in the parent component:this.state.contact
is then passed down toContactSelect
in thecontact
prop, which is why it is seen in my original post asthis.props.contact
.