Skip to content

Commit

Permalink
refactor: pagination is now a state without setter
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroferreira1 committed Sep 24, 2024
1 parent 442b7be commit 05f8424
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/components/tx/Transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import React, { useCallback, useEffect, useMemo, useState } from 'react';
import React, { useCallback, useEffect, useState } from 'react';
import ReactLoading from 'react-loading';
import { Link, useLocation } from 'react-router-dom';
import { reverse } from 'lodash';
Expand Down Expand Up @@ -33,9 +33,10 @@ import PaginationURL from '../../utils/pagination';
* page = "next"
*/
function Transactions({ shouldUpdateList, updateData, title }) {
// We must use memo here because we were creating a new pagination
// object in every new render, so the useEffect was being called forever
const pagination = useMemo(
// We can't use a simple variable here because it triggers a re-render everytime.
// useMemo was discussed but the idea is not to have a cache, it's more like
// a state without setter.
const [pagination,] = useState(
() =>
new PaginationURL({
ts: { required: false },
Expand Down

0 comments on commit 05f8424

Please sign in to comment.