My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

How do I create new option if there are no left in React-Select?

Jan Sedloň's photo
Jan Sedloň
·Dec 14, 2018

I need to create new option with label "Ostatni" if there are no options left. I tried to do it by customising MenuList and NoOptionsMessage, but nothing works. Is there any way?

I tried it this way

NoOptionsMessage = props => (
    <components.NoOptionsMessage
        {...props}
        children={<components.Option {...components.Option.defaultProps} data={{ value: 37, label: 'Ostatni' }} />}
    />
)