This is simple code which can save some of your time, if you trying to build Select field for timezones. Find below for complete Timezones code

Timezones

Find below for Timezones.js which contains all timezone names and values
export default [
    {"value":"America/Adak","name":"Adak"},
    {"value":"America/Anchorage","name":"Anchorage"},
    {"value":"America/Anguilla","name":"Anguilla"},
    {"value":"America/Antigua","name":"Antigua"},
    .....
  ];

Normal Select Box

This normal select box in which Timezones were mapped as options
<select value={this.state.timezone} onChange={this.onSelect}>
           {Timezones.map((timezone) => <option value={timezone.value}>{timezone.name}</option>)}
</select>

React-bootstrap Select box

This Select box uses bootstrap styles and components
<FormControl value={this.state.timezone} onChange={this.onSelect} componentClass="select" placeholder="select">
    {Timezones.map((timezone) => <option value={timezone.value}>{timezone.name}</option>)}
</FormControl>

React-select Select box

react-select is React version of Select2. 
<Select value={this.state.timezone} onChange={this.onSelect2} placeholder="select" options={Timezones} labelKey="name" valueKey="value">
</Select>

Complete component code

import 'bootstrap/dist/css/bootstrap.min.css';
import 'react-select/dist/react-select.min.css';
import React from 'react';
import Timezones from './Timezones';
import {FormControl} from 'react-bootstrap';
import Select from 'react-select';

export default class App extends React.Component {

  constructor(props) {
    super(props);
    this.state = {
      timezone:'America/Aruba'
    }
    this.onSelect = this.onSelect.bind(this);
    this.onSelect2 = this.onSelect2.bind(this);
  }

  onSelect(event) {
    this.setState({
      timezone:event.target.value
    });
  }

  onSelect2(language) {
    this.setState({
      timezone:language.value
    });
  }

  render() {
    return (
      <div>
        <h1>Select box for Timezones</h1>
        <select value={this.state.timezone} onChange={this.onSelect}>
           {Timezones.map((timezone) => <option value={timezone.value}>{timezone.name}</option>)}
        </select>
        <br/><br/><br/>
        <h1>Bootstrap Select box for Timezones</h1>
        <FormControl value={this.state.timezone} onChange={this.onSelect} componentClass="select" placeholder="select">
          {Timezones.map((timezone) => <option value={timezone.value}>{timezone.name}</option>)}
        </FormControl>
        <br/><br/><br/>
        <h1>React Select2 for Timezones</h1>
        <Select value={this.state.timezone} onChange={this.onSelect2} placeholder="select"
           options={Timezones} labelKey="name" valueKey="value">
        </Select>
      </div>
    )
  }
}

33 comments:

  1. Hi there, You've done an incredible job. I will definitely digg it and in my view suggest to my friends.I am sure they will be benefited from this web site.
    kissmanga

    ReplyDelete
  2. nice blog...looking for more useful information....For Online accounting services please visit here:
    https://meralegal.com/accounting.php

    ReplyDelete
  3. Thank you for this informative post

    Get Six Sigma Certification Online with HenryHarvin.
    Learn from experts and be on top

    ReplyDelete
  4. ERP Gold Software
    How ERP Gold works as an inventory management software for Walmart
    Why do sellers on Walmart need inventory management software?
    Inventory management involves the process of ordering, handling, storing, and processing a company’s inventory. This has done because, without an effective inventory management system, the full potential of the supply chain becomes unattainable.
    For more information about ERP Gold inventory management software, please click on the link below.
    https://www.erp.gold/walmart-erp-integration-software/

    ReplyDelete
  5. Thanks for sharing a really very nice and wonderful article i like your blog too much

    ReplyDelete
  6. Thank you for sharing your info. I really appreciate your efforts and I am waiting for your further write ups thank you once again.Electrical design for building construction


    ReplyDelete
  7. Have seen this thing on a few different website and wanted to do it for some time. Now I can say I am able to do it efficiently:
    buy logo

    ReplyDelete
  8. I am the one who writes on a topic similar to yours. I hope you come to my blog and take a look at the posts I've been writing. 메이저놀이터검증

    ReplyDelete
  9. Great Blog...thanks for sharing with us...and i have some information about Sumadhura Horizon is a residential project developed by Sumadhura Infracon Pvt. Ltd, located in Kondapur, Hyderabad. It is provides 3BHK Luxury Flats in affordable prices.

    Sumadhura Horizon
    Sumadhura Horizon Hyderabad
    Sumadhura Horizon Kondapur

    ReplyDelete
  10. I really like your blog thanks for sharing...and i have some information about Ambience Courtyard developed by Koncept Ambience Group, located in Manikonda, Hyderabad. Project provides 2,2.5 & 3bhk bedroom luxury flats available for sale in affordable prices.

    Ambience Courtyard
    Ambience Courtyard Hyderabad
    Ambience Courtyard Manikonda
    Ambience Courtyard Manikonda Hyderabad


    ReplyDelete
  11. Your selection of topic is very good and also well written. Thanks for sharing. I feel like all your ideas are incredible! Great job!!!
    I have some information about:
    Brigade Citadel
    Pooja Magic Breeze
    Ramky One Harmony
    Luxury Park 2

    ReplyDelete
  12. Thanks for your sharing great article, I am very happy to read this article and I like it very much!I would also recommend it to my friends.
    sun news live
    sun news
    sun tv live
    news 7 live
    sun news live today
    sun tv news
    sun tv news live
    sun tv live news
    சன் நியூஸ்
    thanthinews

    ReplyDelete
  13. I enjoyed reading your post.You make so many great points here that I read your article a couple of times.
    Luxury Park 2
    Luxury Park 2 Mamidipally
    Luxury Park 2 Hyderabad

    ReplyDelete
  14. I love the way you write and share your niche! Very interesting and different! Great job!!! I have some information about:
    Ramky One Harmony
    Ramky One Harmony Pragathi Nagar
    Ramky One Harmony Hyderabad
    Ramky One Harmony Pragathi Nagar Hyderabad

    ReplyDelete
  15. Many thanks for the article, I have a lot of spray lining knowledge but always learn something new. Keep up the good work and thank you again. 토토사이트

    ReplyDelete
  16. I’m writing on this topic these days, , but I have stopped writing because there is no reference material. Then I accidentally found your article. I can refer to a variety of materials, so I think the work I was preparing will work! Thank you for your efforts. 경마사이트

    ReplyDelete
  17. You completely match our expectation and the variety of our information 바카라사이트

    ReplyDelete
  18. My name is Upan, I have more than 3 years of experience in Shopify dropshipping store development and products listing. I help my clients to boost their sales by importing the best product reviews for their products.

    Will you import reviews from aliexpress to shopify?
    Order Link: https://www.fiverr.com/share/XmW1Em

    ReplyDelete
  19. I like your written way thanks for sharing it with us.


    law dissertation Writers

    ReplyDelete
  20. Thank you so much for this information.

    https://imageexpertindia.com/long-shadow-photoshop-basic-tutorial/
    Creating a drop shadow is a cycle that ought to go with your section as it assists with making your picture look more reasonable. This little realistic detail can truly have an effect since it makes the item more straightforward to examine.

    Reflection Shadow
    Photoshop Shadow Effect Service
    Natural Drop Shadow Service
    Realistic shadow in photoshop
    Floating Shadow Creation
    Castaway Shadow Creation

    ReplyDelete
  21. "This is a really good write up . I loved it .
    Excellent article . Keep up the good work
    Thank you.
    "
    https://groundcyber.com/digital-marketing-course-bareilly/

    ReplyDelete
  22. Servis PK is an Online Official Store, where you can buy formal shoes for men in all sizes with various colors at reasonable Prices. We deliver a product on COD in all Metro cities like Lahore, Karachi, Islamabad across Pakistan.

    ReplyDelete
  23. Thank you for your insight! https://firstclass.marketing/

    ReplyDelete
  24. I dark web sites
    have more than 3 years of experience in Shopify

    ReplyDelete

Blogroll

Popular Posts