Skip to content

Managing style and state across keys (multiValue clear on click) #5242

Answered by manjushsh
jcamato asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @jaakerisalu please check if this works for you
Code Sandbox

Code:

import React from "react";
import { createRoot } from "react-dom/client";
import Select, { components } from "react-select";
import "./styles.css";

class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = { selectedOption: "" };
  }

  options = [
    { value: "Spring", label: "Spring" },
    { value: "Summer", label: "Summer" },
    { value: "Autumn", label: "Autumn" },
    { value: "Winter", label: "Winter" }
  ];

  handleChange = (selectedOption) => {
    this.setState({ selectedOption });
  };

  onChipClick = (chipData) =>
    this.setState({
      selectedOption: this…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@jcamato
Comment options

@jcamato
Comment options

@manjushsh
Comment options

@jcamato
Comment options

@manjushsh
Comment options

Answer selected by jcamato
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants