Skip to content

Instantly share code, notes, and snippets.

@brendalong
Last active November 9, 2021 20:02
Show Gist options
  • Save brendalong/a142695a3f34dd9b9b0dbf6799b86ee6 to your computer and use it in GitHub Desktop.
Save brendalong/a142695a3f34dd9b9b0dbf6799b86ee6 to your computer and use it in GitHub Desktop.

Give me a Quote

Create a self contained component that will display a single quote. Use the following api: https://type.fit/api/quotes

NOTE You will only be calling the API one time and saving the data in state.

You will be using useState and useEffect

Step 1

Create the JSX that displays a placeholder for the dynamic content and return to display on the DOM. You will be displaying the quote and the author.

Step 2

useEffect to fetch the quote data

Step 3

useState to store quote data

Step 4

Create a function that will extract a single quote and displayed it in the JSX you wrote in Step 1

BONUS 1

Instead of displaying quote[index], create a function that will choose a random quote and display it.

BONUS 2

Add a button that when clicked will display a different quote.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment