Comments (13)
A solution could be to add another props like onLoad/onMount
if is needed to call the handler when component is loaded.
from react-paginate.
Looks like if you use initialSelected
it will invoke the click callback on load but if you use forceSelected
it will not.
from react-paginate.
Yes indeed. So, you're right, adding a boolean flag to change this behaviour if needed may be a good idea.
from react-paginate.
Hello @hackingbeauty,
Indeed, when react-paginate first gets displayed on a page, it automatically calls the clickCallback handler. That's because the clickCallback function is supposed to be the place where you load the content you want to display on a particular page.
As you can initialize the component to display the page of your choice (page 6 for example), it will call the clickCallback at first in order to load the content of page 6.
I hope this helps.
from react-paginate.
the first data has been fetched, then the callback
will fetch duplicated data again.
i don't think automatically calls the clickCallback is good.
from react-paginate.
Having issues because of this too.
Data is loaded from other method.
onClick handles a pushState to a new url with the new page number.
Being called on mount causes me a loop.
from react-paginate.
Might this be causing an issue where my initial page is linked to [2], where as [1] links to a non existent page-0 ? I created this ticket btw: #104
from react-paginate.
One thing i just noticed is that the demo provided on this repo doesn't call the 'clickCallback' on load.
from react-paginate.
@terencechow spot on, seems to be working on my end using forceSelected
. The click callback is no longer being invoked on render.
from react-paginate.
For your information, since react-paginate 3.0.0, the clickCallback
(=onPageChange
) isn't called anymore during initialization.
from react-paginate.
@AdeleD I can see here that it is still being called.
Would you be open to PR where I add bool flag whether to call it or not on initial render?
from react-paginate.
Yes the callback is still called because: #116
If you don't want the callback being called during initialization, don't pass prop initialPage
when you initialize the component.
<ReactPaginate previousLabel={"previous"}
nextLabel={"next"}
initialPage={1} // Remove this line
pageCount={this.state.pageCount}
onPageChange={this.handlePageClick} />
Is it OK for you this way?
from react-paginate.
By removing that line, callback will not be called. This works if you always have initialPage={1}
, but won't work if you need to change initial page.
from react-paginate.
Related Issues (20)
- BUG in initialPage props
- page active link working immediately after clicking before redirecting to that page how to solve this
- pageCount only accepts number but I want to pass a string
- Can't use React <Suspense>? HOT 2
- can i use it in nextjs? HOT 4
- ARIA role should be appropriate for the element HOT 6
- Page active style issue - How to set page 1 as active? HOT 3
- Warning - The pageCount prop value provided is not an integer HOT 12
- Rendering Error HOT 1
- AxeMonitor accessibility issue with react-paginate HOT 1
- Does React-paginate allow you to set the current page?
- Render issues on Next.js 13.5.4 after upgrading from 13.4.12 HOT 37
- How to add custom pageviews
- module tippy not found
- render issue on [email protected] HOT 1
- next/previousLabel keep unused li in DOM
- Props applying to same elements. HOT 1
- Error: Super expression must either be null or a function HOT 1
- Accessing to ref HOT 1
- ReactPaginate
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-paginate.