Currency Converter using React Js
check the code- https://github.com/Saadhya/React-Explorer
Created the project currency converter using ReactJs Tech Stack. Build it with chai or code #chaiorcode #reactjs #tailwind.css
Used several built-in react hooks
React hooks are used in functional components. Like useId(), useEffect(), useCallback(), useState().
Where,
useState()\= Its a basic react hook and most important hook, which is used to update the state in React functional components
useId()\= Its a brand new react hook used for generating unique Id.
useEffect() = used to run and manage the component with an external system. It is used to mount the component on the DOM under 3 different lifecycle method.
useCallback()= used to return the memoized function by keeping method statements in cache in the component. Its syntax is very similar to useEffect() hook. callback() with dependency array.
created custom hook
function useCurrencyInfo(currency) {
const [data, setData] = useState({});
const url = `https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/${currency}.json`;
useEffect(() => {
fetch(url)
.then((res) => res.json())
.then((res) => setData(res[currency]));
console.log(data);
}, [currency]);
return data;
}