import type { JSX } from 'react' import { useState } from 'react' import styles from './Quotes.module.css' import { useGetQuotesQuery } from './quotesApiSlice' const options = [5, 10, 20, 30] export const Quotes = (): JSX.Element | null => { const [numberOfQuotes, setNumberOfQuotes] = useState(10) // Using a query hook automatically fetches data and returns query values const { data, isError, isLoading, isSuccess } = useGetQuotesQuery(numberOfQuotes) if (isError) { return (

There was an error!!!

) } if (isLoading) { return (

Loading...

) } if (isSuccess) { return (

Select the Quantity of Quotes to Fetch:

{data.quotes.map(({ author, quote, id }) => (
“{quote}”
))}
) } return null }