I can’t seem to get a select element to have options based on elements of an array in state. I’ve tried a bunch of different methods, but this seemed to be the most granular (I’m just getting back into react after a few years, and am trying to relearn it).
I have a whole stateful component for the dropdown, shown below:
import React, { Component } from "react";
import "./Dropdown.css";
class Dropdown extends Component {
constructor(props) {
super(props);
this.state = {
options: [],
selectedOption: "",
};
};
componentDidMount = () => {
this.setState({
options: this.props.options
});
};
displayOptions = () => {
this.state.options.map(item => {
return <option value={item} id="1">{item}</option>
});
};
render() {
return(
<select className="dropdown">
{ this.displayOptions() }
</select>
)
};
};
export default Dropdown;
The props that are being pulled in are structured as an array of either strings or numbers. As an example:
[2020,2019,2018,2017,2016,2015,2014,2013,2012,2011,2010,2009,2008,2007,2006,2005,2004,2003,2002,2001,2000,1999,1998,1997,1996,1995,1994,1993,1992]
Looking at my React dev tools, state is getting correctly populated with the array. And according to my understanding of React, once state is populated, the component should rerender, calling displayOptions, mapping through the array, and filling the select element with option elements.
But when I go to the actual page, no matter how long I wait or what I do, the dropdown never opens to show options. I guess I can’t tell if I just have a typo that’s keeping this from working properly, or if I’m missing a larger rule of either React, array prototypes, or something else entirely.
Any help would be greatly appreciated. And please let me know if more information is needed. I feel like I’ve provided all relevant info, but I’m happy to provide more if needed.
india buy prednisone online – prednisone 1 mg tablet prednisone online australia
where can i buy accutane online – price for generic accutane accutane price uk
generic amoxicillin at walmart’s website – amoxil 250 buy amoxicillin 500 mg online canada
how long does vardenafil last – vardenafil dosage canadian pharmacy generic vardenafil
med pharmacy – cialis 5 mg tablet order cialis without a prescription
ivermectin 2mg – ivermectin generic cream
amoxicillin 500 mg for sale – amoxicillin 500mg capsules for sale rx amoxicillin 500mg
modafinil anxiety – generic provigil provigil 200 mg
can you buy lasix in mexico without a prescription – lasix 40mg furosemide 100
get viagra prescription online – viagra soft tabs uk buying viagra without prescription
buy cialis online with mastercard – generic cialis availability cialis 2.5 mg tablet
ivermectin over the counter canada – stromectol order ivermectin 3mg tab
casino slots gambling – online casino games casino slots gambling
what causes ed – ed pills for sale erectile dysfunction age
prednisone 50 mg buy – prednisone 20 mg without prescription prednisone otc price
viagra super active price – sildenafil buy paypal sildenafil 20 mg tablet brand name
brazilian pharmacy online – Cialis women buy tadalafil 20mg uk
ivermectin medicine – ivermectin human ivermectin oral 0 8
over the counter erectile dysfunction pills – what type of medicine is prescribed for allergies erectile dysfunction natural treatment
ventolin medication – ventolin price uk albuterol sulfate
where can i buy misoprostol – cost cytotec generic cytotec over the counter uk
doxycycline 400 mg price – 22 doxycycline doxycycline pills cost
neurontin brand name 800mg – best price for levothyroxine 137 mcg levothyroxine pill 88mg
viagra india online pharmacy – can you buy viagra over the counter in south africa
cheap generic cialis india – cialis for sale uk tadalafil tablets 20 mg online india
cheap levitra – levitra for sale vardenafil price
ivermectin nz – ivermectin pill cost ivermectin price comparison
isotretinoin 40 mg – cheapest accutane generic cheap accutane for sale
antibiotic amoxicillin for sale – can you buy amoxicillin over the counter can you buy amoxicilin over the counter
methylprednisolone dose pack no presciption – lyrica medicine price lyrica price
frusemide tablets 40mg furosemide price walgreens nek nox
hire essay writer – essaymbp.com academicwriting
sildenafil tablets in india – Canada meds viagra buy real viagra online in india
furosemide india – clomid 50mg lasix generic
albuterol without prescription – ventolin price uk buy ventolin
buy cytotec online with paypal – buy cytotec online canada cytotec 200mcg
ivermectin cost uk ivermectin 1mg
doxycycline cost united states – doxycycline order online canada prednisolone prices
stromectol ireland – ivermectina online ivermectin 0.5 lotion india
ivermectine – stromectol generic name stromectol for sale
generic sildenafil cost – generic name for sildenafil sildenafil without doctor prescription
clomid online shop nek nox
buy tadalafil online overnight shipping – best place to buy tadalafil online reviews tadalafil generic name
clomid over the counter walgreens nek nox
accutane 20 mg – accutane 5 mg accutane 20 mg price uk
cheap custom essay – write essay service essay writers online
viagra 50mg – Cialis samples eli lilly cialis
buy vardenafil paypal – vardenafil price erectile dysfunction doctors near me
mylan hydroxychloroquine – prednisone 60mg tablets prednisone 5 mg tablet without a prescription
where to buy ivermectin – ivermectin tablet stromectol 0.1
sildenafil 50 mg online uk – viagra 100 mg online viagra canadian pharmacy online
buy cialis for daily use online – cialis 100mg china tadalafil drug
buying prednisone online – where to buy prednisone uk steroid prednisone
how to buy tadalafil – buy cheap cialis tadalafil for sale canada
cost of ivermectin cream – buy stromectol for humans australia stromectol pill price
ivermectin 9 mg tablet – ivermectin tablet price buy oral ivermectin
sildenafil 50 – pfizer viagra 50mg female viagra pill online
best cheap cialis – cialis from canada how much does cialis cost
casino slots gambling – site real casino
sildenafil pills canada – Buy viagra australia average cost for viagra
ivermectin 12mg oral – ivermectin 12mg stromectol ivermectin 80 mg
buy prednisone online cheap – buy prednisone without prescription prednisone drugs
ivermectin pyrantel pamoate ivermectin liquid ivermectin cost
tractor supply ivermectin ivermectin toxicity treatment
cheap generic cialis in the us adderall and cialis
example of a thesis statement for an essay thesis compare and contrast essay example
order sildalis without prescription – buy glucophage 500mg pills cost glucophage 1000mg
buy generic viagra 50mg – viagra 150mg pills order cialis 40mg generic
acheter 50mg gГ©nГ©rique sildenafil en france – acheter 200mg gГ©nГ©rique viagra en france tadalafil 20mg generique en pharmacie
tadalafil daily online prescription tadalafil online
tadalafil cost in canada what is tadalafil
atarax 10mg cost – crestor 10mg pills rosuvastatin for sale online
tadalafil cost in canada buy tadalafil
https://cialisicp.com/ tadalafil cost walmart
cost tadalafil generic tadalafil drug
canada generic tadalafil prescription tadalafil online
generic tadalafil from uk tadalafil order online no prescription
price of viagra viagra generic online
liquid tadalafil cialis soft
tadalafil online buy tadalafil
generic viagra generic viagra review
tadalafil online with out prescription https://cialisvet.com/
stromectol in usa ivermectin pills stromectol
viagra online fast delivery where to buy female viagra buy generic viagra online pharmacy
cialis 200 mg no prescription cialis reliable sites cialis 20 mg price
pink viagra for women us pharmacy viagra prices price for sildenafil 100 mg
cialis side effects forum cialis 30 mg dose buy cialis canadian
sildenafil 100mg online otc viagra pills sildenafil 25 mg cost
cialis 20mg side effects sell cialis truth behind generic cialis
cialis online 2nd day shipping tadalafil natural source blak cialis
viagra rx cost online canadian pharmacy viagra buy sildenafil
Augmentin Suhagra Nimotop