Sign in
Log inSign up

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' }} />}
    />
)
Hassle-free blogging platform that developers and teams love.
  • Docs by Hashnode
    New
  • Blogs
  • AI Markdown Editor
  • GraphQL APIs
  • Open source Starter-kit

© Hashnode 2024 — LinearBytes Inc.

Privacy PolicyTermsCode of Conduct