Answer the question
In order to leave comments, you need to log in
How to simplify the condition for the paginator?
https://repl.it/@fomenkogregory/Paginator-5#src/App.js
I created such a paginator, how to simplify the condition without changing the behavior? Help.
Answer the question
In order to leave comments, you need to log in
Let's put into separate variables the conditions that determine whether it is necessary to show groups of buttons that ...
// ...прилегают к первой кнопке
const showAfterFirst = currentPage < 5;
// ...прилегают к последней кнопке
const showBeforeLast = currentPage > totalPages - 4;
!showAfterFirst
and !showBeforeLast
. And to display the central group of buttons, both base conditions must be false: !(showAfterFirst || showBeforeLast)
. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question