File tree Expand file tree Collapse file tree 3 files changed +12
-13
lines changed
Expand file tree Collapse file tree 3 files changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -7,18 +7,10 @@ import Layout from "./components/Layout/Layout";
77function App ( ) {
88 const [ search , setSearch ] = useState ( "" ) ;
99 const [ type , setType ] = useState ( "" ) ;
10- const [ countStar , setCountStar ] = useState ( 0 ) ;
11-
12- useEffect ( ( ) => {
13- fetch ( "https://api.github.com/repos/devvsakib/github-error-solve" )
14- . then ( ( response ) => response . json ( ) )
15- . then ( ( data ) => setCountStar ( data . stargazers_count ) )
16- . catch ( ( error ) => console . error ( "Error fetching GitHub stars:" , error ) ) ;
17- } , [ ] ) ;
18- console . log ( countStar )
10+
1911 return (
2012 < >
21- < Layout stars = { countStar } >
13+ < Layout >
2214 < SearchInput search = { search } setSearch = { setSearch } setType = { setType } />
2315 < Error search = { search } type = { type } />
2416 </ Layout >
Original file line number Diff line number Diff line change @@ -10,11 +10,19 @@ import { Link } from "react-router-dom";
1010
1111import { HiMoon , HiSun } from "react-icons/hi" ;
1212import { ThemeContext } from "../../context/ThemeContext" ;
13- import { useContext , useState } from "react" ;
13+ import { useContext , useState , useEffect } from "react" ;
1414
15- function Header ( { countStar , notice } ) {
15+ function Header ( { notice } ) {
1616 const { theme, toggleTheme } = useContext ( ThemeContext ) ;
1717 const [ open , setOpen ] = useState ( false ) ;
18+ const [ countStar , setCountStar ] = useState ( 0 ) ;
19+
20+ useEffect ( ( ) => {
21+ fetch ( "https://api.github.com/repos/devvsakib/github-error-solve" )
22+ . then ( ( response ) => response . json ( ) )
23+ . then ( ( data ) => setCountStar ( data . stargazers_count ) )
24+ . catch ( ( error ) => console . error ( "Error fetching GitHub stars:" , error ) ) ;
25+ } , [ ] ) ;
1826
1927 const navLink = [
2028 {
Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ const Layout = ({ stars, children }) => {
1313 < div className = 'flex flex-col justify-between min-h-screen' >
1414 < ThemeProvider >
1515 < Header
16- countStar = { stars }
1716 notice = { "Under Construction" }
1817 />
1918 < div className = 'relative' >
You can’t perform that action at this time.
0 commit comments