Skip to content

Commit

Permalink
Merge pull request #8 from devRabbani/master
Browse files Browse the repository at this point in the history
Fixing pagination issue
  • Loading branch information
devRabbani authored Nov 22, 2021
2 parents 641a51e + 47ed600 commit fc72809
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
25 changes: 15 additions & 10 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import React from "react";
import Home from "./components/Home/index";
import { Switch, Route } from "react-router-dom";
import About from "./components/About";
import Nav from "./components/Nav";
import React, { useState } from 'react'
import Home from './components/Home/index'
import { Switch, Route } from 'react-router-dom'
import About from './components/About'
import Nav from './components/Nav'
const App = () => {
const [pageNo, setPageNo] = useState(0)
return (
<>
<Nav />
<Switch>
<Route path="/" exact component={Home} />
<Route path="/info" exact component={About} />
<Route
path='/'
exact
render={() => <Home pageNo={pageNo} setPageNo={setPageNo} />}
/>
<Route path='/info' exact component={About} />
</Switch>
</>
);
};
)
}

export default App;
export default App
6 changes: 3 additions & 3 deletions src/components/Home/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import React, { useEffect, useState } from 'react'
import { Link } from 'react-router-dom'
import './Home.css'

const Home = () => {
const Home = ({ pageNo, setPageNo }) => {
const [image, setImage] = useState([])
const [dataFull, setDataFull] = useState([])
const [searchString, setSearchString] = useState('')
const [pageNo, setPageNo] = useState(0)
// const [pageNo, setPageNo] = useState(0)

const handleNext = () => {
setPageNo((prev) => prev + 1)
Expand Down Expand Up @@ -106,7 +106,7 @@ const Home = () => {
<span>
<p>{pageNo + 1}</p>
</span>
<button disabled={pageNo === 6} onClick={handleNext}>
<button disabled={pageNo === 5} onClick={handleNext}>
Next
</button>
</div>
Expand Down

0 comments on commit fc72809

Please sign in to comment.