Fetching data asynchronously in useEffect
To asynchronously fetch data in a React component using hooks, we can define and then call an asynchronous function inside of useEffect.
Read full articleconsole
is an object like any other. That means we can destructure from it like we do with other objects as well. The saved keystrokes might harm readability, so use this at your own discretion.
// Tired of writing “console.” all the time?
console.log("This sure is tiresome.")
console.warn("That’s a lotta keystrokes.")
// Destructure the functions from the console object.
const { log, warn } = console
log("Look ma, no console!")
warn("I’m going to let you do whatever.")
// Tired of writing “console.” all the time?
console.log("This sure is tiresome.")
console.warn("That’s a lotta keystrokes.")
// Destructure the functions from the console object.
const { log, warn } = console
log("Look ma, no console!")
warn("I’m going to let you do whatever.")
// Tired of writing “console.” all the time?
console.log("This sure is tiresome.")
console.warn("That’s a lotta keystrokes.")
// Destructure the functions from the console object.
const { log, warn } = console
log("Look ma, no console!")
warn("I’m going to let you do whatever.")
// Tired of writing “console.” all the time?
console.log("This sure is tiresome.")
console.warn("That’s a lotta keystrokes.")
// Destructure the functions from the console object.
const { log, warn } = console
log("Look ma, no console!")
warn("I’m going to let you do whatever.")
To asynchronously fetch data in a React component using hooks, we can define and then call an asynchronous function inside of useEffect.
Read full articleWith this helper function, we can map over objects and change each of their values like we would do with arrays.
Read full articleSince array methods like filter and map return an array themselves, we can chain them one after the other.
Read full articleWe can split an array in two based on a condition: matches go in the first array, everything else goes in the second.
Read full articleTemplate literals allow us to put the values of variables, the results of calculations, and even return values of function calls into strings.
Read full articleWe can turn arrays of absolute numbers into relative numbers. The largest value becomes 1, with the others calculated based on that largest value.
Read full article