0

I'm new to react, learning new things in react and have created a dropdown for a country and want store the value in app.js. I couldn't able to get the value from the dropdown field. Can anyone help me to get the value?

Here is the some code:

<Select
          placeholder="Select your country"
          options={countryOptions}
          value={this.props.country}
          onChange={this.props.handleCountry}
        />

Here is the whole code:

"https://codesandbox.io/s/charming-bell-elme4".

Can anyone help me in this?

1 Answer 1

1

It looks like handleCountry should accept two params:

  handleCountry = (e, obj) => {
    this.setState({
      country: obj.value
    });
  };

See this fork for a working example. Hope that helps!

Sign up to request clarification or add additional context in comments.

3 Comments

Hi, I coudn't able to open sandbox to see the working one. Could you please update it again?
The link is working for me. Not sure what to update. codesandbox.io/s/romantic-hill-lh3tf?file=/src/App.js:278-365
Note, I also updated the submit button: <Button onClick={this.onSubmit}>Submit</Button>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.