Git Product home page Git Product logo

Comments (5)

adamwade2384 avatar adamwade2384 commented on July 20, 2024

Having the same issue. Did you end up finding a solution to this?

from react-dropdown.

LoganArnett avatar LoganArnett commented on July 20, 2024

@adamwade2384 I am not sure if I resolved this as it was so long ago, but I will check that project to see if I did find an answer for it

from react-dropdown.

LoganArnett avatar LoganArnett commented on July 20, 2024

@adamwade2384 It appears that I gave up on the component and created my own in a similar fashion that was able to be used multiple times in the same component, I can share the basic code I have for that if you would like

from react-dropdown.

fraserxu avatar fraserxu commented on July 20, 2024

@adamwade2384 @LoganArnett Mind create a codesandbox or codepen example so I could check? The example page is rendering multiple dropdowns without any issue. http://fraserxu.me/react-dropdown/

from react-dropdown.

Danielauler avatar Danielauler commented on July 20, 2024

I solve this problem handling with dynamically states.

export default class Dropdowns extends Component {
constructor(props) {
super();
this.state = {
selected: []
}
}

handleChange(index, value) {
    const selected = [...this.state.selected];
    selected[index] = value;
    this.setState({ selected });
}

render() {
   return (
        <section className="column">
            {this.props.arrayHypothetical.map((item, index) => (
              <Dropdown options={this.props.options} value={this.state.selected[index] ?  
              this.state.selected[index] : {value: "0", label: "first"}} placeholder= 
              {this.props.placeholder} onChange={(val) => this.handleChange(index, val} />
            )}
        </section>
    );
}

}

this.props.arrayHypothetical it's just a hypothetical array of items with dropdown. (Sorry, it's my first comment, I don't know how to indent)

from react-dropdown.

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.