Arkadaşlar merhaba,
Yeni olduğum bir konu, araştırdım ancak çözemedim, yardımınızı rica ediyorum.
Kendimi geliştirme amaçlı bir React projesi yapıyorum, hooklarla çalışacağım.
Aşağıda ki gibi bir dosya var diyelim, aslında api dan çekeceğim,
map fonksiyonu ile istediğim detayı sayfamda göstermek istiyorum.
Bir çok şey denedim, araştırdım ancak sanırım doğru yerlere bakmadım ki çözümü bulamadım.
Deneme amaçlı yazdığım her kodu buraya aktarıp uzatmak istemediğimden temelde üzerinde durduğum halini ekliyorum, hedefe götürecek her fikre açığım, doğru format(-lar) nedir, nasıl bir yol izelemeli, ana fikri verebilirseniz yeter, tüm kodu istemiyorum, balık vermeyin balık tutmayı öğretin
Şimdiden teşekkür ederim.
import React from 'react';
export default function ValueRef() {
const liste = {
"location_suggestions": [
{
"id": 61,
"name": "London",
"country_id": 215,
"country_name": "United Kingdom",
"country_flag_url": "https://b.zmtcdn.com/images/countries/flags/country_215.png",
"should_experiment_with": 0,
"has_go_out_tab": 0,
"discovery_enabled": 0,
"has_new_ad_format": 0,
"is_state": 0,
"state_id": 142,
"state_name": "England and Wales",
"state_code": "England and Wales"
},
{
"id": 3454,
"name": "London, ON",
"country_id": 37,
"country_name": "Canada",
"country_flag_url": "https://b.zmtcdn.com/images/countries/flags/country_37.png",
"should_experiment_with": 0,
"has_go_out_tab": 0,
"discovery_enabled": 0,
"has_new_ad_format": 0,
"is_state": 0,
"state_id": 124,
"state_name": "Ontario",
"state_code": "ON"
},
{
"id": 5836,
"name": "London, KY",
"country_id": 216,
"country_name": "United States",
"country_flag_url": "https://b.zmtcdn.com/images/countries/flags/country_216.png",
"should_experiment_with": 0,
"has_go_out_tab": 0,
"discovery_enabled": 0,
"has_new_ad_format": 0,
"is_state": 0,
"state_id": 85,
"state_name": "Kentucky",
"state_code": "KY"
},
],
"status": "success",
"has_more": 0,
"has_total": 0,
"user_has_addresses": true
}
console.log( liste)
return (
<div>{
Object.values(liste).map((detay)=>(<div>{detay}</div>))
}</div>
)
}
Error: Objects are not valid as a React child (found: object with keys {id, name, country_id,
country_name, country_flag_url, should_experiment_with, has_go_out_tab, discovery_enabled,
has_new_ad_format, is_state, state_id, state_name, state_code}). If you meant to render a collection
of children, use an array instead.