Skip to content

digafem/Digafe-random-quotes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

import React, { useState, useEffect } from 'react'; import './App.css' function App() { const [quotes, setQuotes] = React.useState(""); const [randomQuote, setRandomQuote] = React.useState(""); React.useEffect(() => { async function fetchData() { const response = await fetch("https://type.fit/api/quotes") const data = await response.json(); setQuotes(data); let randIndex = Math.floor(Math.random() * data.length); setRandomQuote(data[randIndex]); } fetchData(); }, []); const getNewQuote = () => { let randIndex = Math.floor(Math.random() * quotes.length); setRandomQuote(quotes[randIndex]); } return ( <>

"{randomQuote.text}"

-{randomQuote.author}
tweat tumblr New Quote
) } export default App const colors = [ "#16a085", "#27ae60", "#2c3e50", "#f39c12", "#e74c3c", "#fb6964", "#9b59b6", "#342224", "#73AB57", "#2c3e90", ]let randIndex = Math.floor(Math.random() * quotes.length); setRandomQuote(quotes[randIndex]); setColor(colors[randColorIndex]) # Digafe-random-quotes

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published