I would like to render a simple list but it seems that react can't render unclosed pushed html elements. But it results an error
ReferenceError: el is not defined
if use simple quotes (')
bookingStatusList.push('<div className="select"><select id="department">');
The error is gone but the <div>
and the <select>
html is rendered as text and not html tags (the <option>
are properly rendered)
render()
{
const {bookingStatus} = this.state;
const bookingStatusList = [];
if(bookingStatus.length)
{
bookingStatusList.push(<div className="select"><select id="department">);
bookingStatus.map(el => {
bookingStatusList.push (
<option value={el.id} key={el.id}>
{el.name}
</option>
)
})
bookingStatusList.push(</select></div>)
}
else
{
bookingStatusList.push('<div>LOADING</div>')
}
return (
<div>
{bookingStatusList}
</div>
);
}
el
supposed to refer too? – etarhanbookingStatus.map(id => {
change it tobookingStatus.map(el => {
– Vladimir BogomolovbookingStatus.map(id => {
tobookingStatus.map(el => {
– Shibon