Code Monkey home page Code Monkey logo

Comments (3)

JoeVanGundy avatar JoeVanGundy commented on May 24, 2024

Been trying to track this down the exact cause of this issue.
I added the custom ValueContainer and closeMenuOnSelect={false} to your example, and it functioned ok.
So it seems like something about updating the chosen values in state.
Let me know if there's anything I can do to help to debug or solve to help solve this asap!

https://codesandbox.io/s/chakra-react-select-custom-option-forked-dfisb?file=/example.js

from chakra-react-select.

csandman avatar csandman commented on May 24, 2024

Check out this statement from the original react-select docs:

Defining components

When defining replacement components, it is important to do so outside the scope of rendering the Select. Defining a replacement component directly in the components prop can cause issues.

On this topic, React documentation has the following to say:

The problem here isn’t just about performance β€” remounting a component causes the state of that component and all of its children to be lost.

This statement applies as well when replacing components in react-select with inline definitions.

So if you move the custom components definition outside of the body of the Select component it should work. I updated your example: https://codesandbox.io/s/chakra-react-select-custom-option-forked-8o389b?file=/example.js

That's my bad however for writing it that way in the docs in the first place. The issue doesn't crop up unless the state of the component changes (hence why using the value from state broke it) so I had forgotten that this was an issue. I will update the docs to show that the component should be defined on the outside.

from chakra-react-select.

csandman avatar csandman commented on May 24, 2024

I'm going to close this because a solution was offered and there has been no activity in a while, let me know if the solution did not work

from chakra-react-select.

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.