30 Days of React: Day 08 | States
- CSS reset - version 1.7.2 by @elad2412 used
- Styling done mostly inline (javascript)
- Q&A incorporated to CRA page using level1qna.js
- Added a custom function hasCode.js to personal library
- Utilized hooks on functional components:
useState
anduseEffect
for fetching flags .svg
- Error:
- 404 on flags URL in data provided
- Solution:
- Used https://restcountries.com to fetch flags .svg and used a default image if flag cannot be found due to country name difference (data name and fetch url path)
const url = `https://restcountries.com/v3.1/name/${name.toLowerCase()}` fetchFlag(url).catch(() => console.log(`Error fetching from ${url}`))
- Done by using fetch API accompanied with
{ useState, useEffect } from 'react'