Jessica Bulldog
Jessica Bulldog

Reputation: 158

object Object in option

I try to get a list of options, component Addreess returns return adrress.features.find(place => place.id.match(region)).text, in tag <p></p> I get actual String, but in options object Object. Why?

<select name="cities" id="cities">
          {data.allContentfulBlogPost.edges.map((edge) => {
            return (
              <Adrress x={edge.node.location.lon} y={edge.node.location.lat} />
            )
          }
          )}
     </select>

Output : <select name="cities" id="cities">WarsawManchester</select>

if I change to

<option value=""><Adrress x={edge.node.location.lon} y={edge.node.location.lat} /></option>

Output :

<select name="cities" id="cities">
  <option value="">[object Object]</option>
  <option value="">[object Object]</option>
</select>

Upvotes: 2

Views: 1496

Answers (1)

andsilver
andsilver

Reputation: 5972

<option> tag only accepts string value inside it. You are passing a JSX expression which is not a string and it is rendered as [object Object] in browser.

Upvotes: 2

Related Questions