File tree Expand file tree Collapse file tree 4 files changed +45
-0
lines changed
Expand file tree Collapse file tree 4 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ import React , { useEffect } from "react" ;
2+ import styles from "./Quote.module.css" ;
3+
4+ function Quote ( ) {
5+ const [ quote , setQuote ] = useState ( "" ) ;
6+
7+ useEffect ( ( ) => {
8+ getQuote ( ) ;
9+ } , [ ] ) ;
10+
11+ //get quote
12+ async function getQuote ( ) {
13+ const response = await fetch ( "https://type.fit/api/quotes/" ) ;
14+ const data = await response . json ( ) ;
15+ let pos = Math . floor ( Math . random ( ) * ( 1642 - 0 ) ) ;
16+
17+ setQuote ( `${ data [ pos ] . text } - ${ data [ pos ] . author } ` ) ;
18+ }
19+
20+ return (
21+ < div className = { styles . quote_of_the_day } >
22+ < h2 > { quote } </ h2 >
23+ </ div >
24+ ) ;
25+ }
26+
27+ export default Quote ;
Original file line number Diff line number Diff line change 1+ .quote_of_the_day {
2+ text-align : center;
3+ color : # 777e90 ;
4+ width : 100% ;
5+ max-height : 80px ;
6+ padding : 0 20px ;
7+ }
Original file line number Diff line number Diff line change 1+ import React from 'react'
2+
3+ function Main ( ) {
4+ return (
5+ < div >
6+
7+ </ div >
8+ )
9+ }
10+
11+ export default Main
You can’t perform that action at this time.
0 commit comments