Giter VIP home page Giter VIP logo

Comments (4)

nickstanish avatar nickstanish commented on July 20, 2024

Closing this because I realized that this can be accomplished with the onChange property - by setting the value as an object and having a labelKey

from react-select-plus.

TrevorBurnham avatar TrevorBurnham commented on July 20, 2024

I would recommend against setting value to be an object rather than a primitive. As the docs say:

The value property of each option should be set to either a string or a number.

Using non-primitive values might work, but there are no guarantees that they'll work with every feature, or that they'll continue to work with future updates.

So I think your best bet is to create a value-option map on your end and perform a lookup from onChange. I know that can be a bit inconvenient, but I'm not keen on making additions to the react-select API without a stronger reason than convenience.

from react-select-plus.

nickstanish avatar nickstanish commented on July 20, 2024

I should have specified that I am referring to the value of the Select (which is an Option and should be an object). I followed the example found here

Options should be provided as an Array of Objects, each with a value and label property for rendering and searching. You can use a disabled property to indicate whether the option is disabled or not.

from react-select-plus.

TrevorBurnham avatar TrevorBurnham commented on July 20, 2024

I should have specified that I am referring to the value of the Select (which is an Option and should be an object)

You've lost me… what do you mean by "the value of the Select" if you're not talking about the value in the context of <Select options={options} value={value} />, which corresponds to option.value for some option object in options and should be a primitive?

from react-select-plus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.