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' }} />}
    />
)