diff --git a/23_Fetching_Data_Using_Hooks/23_fetching_data_using_hooks_boilerplate/src/index.js b/23_Fetching_Data_Using_Hooks/23_fetching_data_using_hooks_boilerplate/src/index.js index e3a43c2..dfcbd93 100644 --- a/23_Fetching_Data_Using_Hooks/23_fetching_data_using_hooks_boilerplate/src/index.js +++ b/23_Fetching_Data_Using_Hooks/23_fetching_data_using_hooks_boilerplate/src/index.js @@ -1,362 +1,77 @@ -import React, { useState } from 'react' -import ReactDOM from 'react-dom' +import React, { useState, useEffect } from 'react' +import axios from 'axios' +import ReactDOM, { findDOMNode } from 'react-dom' + +const Country = ({ + country: { name, capital, flag, languages, population, currency }, +}) => { + const formattedCapital = + capital.length > 0 ? ( + <> + Capital: + {capital} + > + ) : ( + '' + ) + const formattedLanguage = languages.length > 1 ? `Languages` : `Language` -const options = [ - { - value: '', - label: '-- Select Country--', - }, - { - value: 'Finland', - label: 'Finland', - }, - { - value: 'Sweden', - label: 'Sweden', - }, - { - value: 'Norway', - label: 'Norway', - }, - { - value: 'Denmark', - label: 'Denmark', - }, -] - -// mapping the options to list(array) of JSX options - -const selectOptions = options.map(({ value, label }) => ( - -)) + return ( +
{formattedCapital}
++ {formattedLanguage}: + {languages.map((language) => language.name).join(', ')} +
++ Population: + {population.toLocaleString()} +
++ Currency: + {currency} +
+