@@ -210,35 +210,17 @@ If we use async and await we handle the error using try and catch. Let's apply a
210
210
import React , { Component } from ' react'
211
211
import ReactDOM from ' react-dom'
212
212
213
- const Country = ({
214
- country: { name, capital, flag, languages, population, currency },
215
- }) => {
216
- const formatedCapital =
217
- capital .length > 0 ? (
218
- <>
219
- < span> Capital: < / span>
220
- {capital}
221
- < / >
222
- ) : (
223
- ' '
224
- )
225
- const formatLanguage = languages .length > 1 ? ` Languages` : ` Language`
226
- console .log (languages)
213
+ const Country = ({ country: { name, flag, population } }) => {
227
214
return (
228
215
< div className= ' country' >
229
216
< div className= ' country_flag' >
230
217
< img src= {flag} alt= {name} / >
231
218
< / div>
232
219
< h3 className= ' country_name' > {name .toUpperCase ()}< / h3>
233
220
< div class = ' country_text' >
234
- < p> {formatedCapital}< / p>
235
- < p>
236
- < span> {formatLanguage}: < / span>
237
- {languages .map ((language ) => language .name ).join (' , ' )}
238
- < / p>
239
221
< p>
240
222
< span> Population: < / span>
241
- {population . toLocaleString () }
223
+ {population}
242
224
< / p>
243
225
< p>
244
226
< span> Currency: < / span>
@@ -309,37 +291,18 @@ import axios from 'axios'
309
291
const Country = ({
310
292
country: { name, capital, flag, languages, population, currency },
311
293
}) => {
312
- const formatedCapital =
313
- capital .length > 0 ? (
314
- <>
315
- < span> Capital: < / span>
316
- {capital}
317
- < / >
318
- ) : (
319
- ' '
320
- )
321
- const formatLanguage = languages .length > 1 ? ` Languages` : ` Language`
322
- console .log (languages)
323
294
return (
324
295
< div className= ' country' >
325
296
< div className= ' country_flag' >
326
297
< img src= {flag} alt= {name} / >
327
298
< / div>
328
299
< h3 className= ' country_name' > {name .toUpperCase ()}< / h3>
329
300
< div class = ' country_text' >
330
- < p> {formatedCapital}< / p>
331
- < p>
332
- < span> {formatLanguage}: < / span>
333
- {languages .map ((language ) => language .name ).join (' , ' )}
334
- < / p>
335
301
< p>
336
302
< span> Population: < / span>
337
- {population .toLocaleString ()}
338
- < / p>
339
- < p>
340
- < span> Currency: < / span>
341
- {currency}
303
+ {population}
342
304
< / p>
305
+ >
343
306
< / div>
344
307
< / div>
345
308
)
@@ -393,39 +356,17 @@ import React, { Component } from 'react'
393
356
import ReactDOM from ' react-dom'
394
357
import axios from ' axios'
395
358
396
- const Country = ({
397
- country: { name, capital, flag, languages, population, currency },
398
- }) => {
399
- const formatedCapital =
400
- capital .length > 0 ? (
401
- <>
402
- < span> Capital: < / span>
403
- {capital}
404
- < / >
405
- ) : (
406
- ' '
407
- )
408
- const formatLanguage = languages .length > 1 ? ` Languages` : ` Language`
409
- console .log (languages)
359
+ const Country = ({ country: { name, flag, population } }) => {
410
360
return (
411
361
< div className= ' country' >
412
362
< div className= ' country_flag' >
413
363
< img src= {flag} alt= {name} / >
414
364
< / div>
415
365
< h3 className= ' country_name' > {name .toUpperCase ()}< / h3>
416
366
< div class = ' country_text' >
417
- < p> {formatedCapital}< / p>
418
- < p>
419
- < span> {formatLanguage}: < / span>
420
- {languages .map ((language ) => language .name ).join (' , ' )}
421
- < / p>
422
367
< p>
423
368
< span> Population: < / span>
424
- {population .toLocaleString ()}
425
- < / p>
426
- < p>
427
- < span> Currency: < / span>
428
- {currency}
369
+ {population}
429
370
< / p>
430
371
< / div>
431
372
< / div>
0 commit comments