Skip to content

Commit c80d8d0

Browse files
Lazy load Transactions lists for faster UI rendering
1 parent 308b7c1 commit c80d8d0

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

apps/frontend/src/components/cln/BTCWallet/BTCWallet.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import './BTCWallet.scss';
2+
import { lazy, Suspense } from 'react';
23
import PerfectScrollbar from 'react-perfect-scrollbar';
34
import { Spinner, Alert, Card, Col, ButtonGroup } from 'react-bootstrap';
5+
const BTCTransactionsList = lazy(() => import('../BTCTransactionsList/BTCTransactionsList'));
46
import { BitcoinWalletSVG } from '../../../svgs/BitcoinWallet';
57
import { WithdrawSVG } from '../../../svgs/Withdraw';
68
import { DepositSVG } from '../../../svgs/Deposit';
79
import CurrencyBox from '../../shared/CurrencyBox/CurrencyBox';
8-
import BTCTransactionsList from '../BTCTransactionsList/BTCTransactionsList';
910
import { useSelector } from 'react-redux';
1011
import { selectIsAuthenticated, selectWalletBalances } from '../../../store/rootSelectors';
12+
import { Loading } from '../../ui/Loading/Loading';
1113

1214
const BTCWallet = (props) => {
1315
const isAuthenticated = useSelector(selectIsAuthenticated);
@@ -52,9 +54,11 @@ const BTCWallet = (props) => {
5254
</Card>
5355
<Card.Body className="px-4 list-scroll-container">
5456
<div className="text-light btc-transactions-tabs">Transactions</div>
55-
<PerfectScrollbar>
56-
<BTCTransactionsList />
57-
</PerfectScrollbar>
57+
<Suspense fallback={<Loading />}>
58+
<PerfectScrollbar>
59+
<BTCTransactionsList />
60+
</PerfectScrollbar>
61+
</Suspense>
5862
</Card.Body>
5963
</Card.Body>
6064
</Card>

apps/frontend/src/components/cln/CLNWallet/CLNWallet.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import './CLNWallet.scss';
2-
import { useState } from 'react';
2+
import { useState, lazy, Suspense } from 'react';
33
import { motion, AnimatePresence } from 'framer-motion';
44
import PerfectScrollbar from 'react-perfect-scrollbar';
55
import { Card, Col, ButtonGroup, Spinner, Alert, Tab, Nav } from 'react-bootstrap';
6-
6+
const CLNTransactionsList = lazy(() => import('../CLNTransactionsList/CLNTransactionsList'));
7+
const CLNOffersList = lazy(() => import('../CLNOffersList/CLNOffersList'));
78
import { LightningWalletSVG } from '../../../svgs/LightningWallet';
89
import { WithdrawSVG } from '../../../svgs/Withdraw';
910
import { DepositSVG } from '../../../svgs/Deposit';
10-
import CLNTransactionsList from '../CLNTransactionsList/CLNTransactionsList';
1111
import CurrencyBox from '../../shared/CurrencyBox/CurrencyBox';
1212
import { TRANSITION_DURATION } from '../../../utilities/constants';
13-
import CLNOffersList from '../CLNOffersList/CLNOffersList';
1413
import { useSelector } from 'react-redux';
1514
import { selectIsAuthenticated, selectWalletBalances } from '../../../store/rootSelectors';
15+
import { Loading } from '../../ui/Loading/Loading';
1616

1717
const CLNWallet = (props) => {
1818
const isAuthenticated = useSelector(selectIsAuthenticated);
@@ -85,10 +85,14 @@ const CLNWallet = (props) => {
8585
>
8686
<Tab.Content className="h-100 d-flex flex-column">
8787
<Tab.Pane className="h-100 list-scroll-container" eventKey="transactions">
88-
<CLNTransactionsList />
88+
<Suspense fallback={<Loading />}>
89+
<CLNTransactionsList />
90+
</Suspense>
8991
</Tab.Pane>
9092
<Tab.Pane eventKey="offers">
91-
<CLNOffersList />
93+
<Suspense fallback={<Loading />}>
94+
<CLNOffersList />
95+
</Suspense>
9296
</Tab.Pane>
9397
</Tab.Content>
9498
</motion.div>

0 commit comments

Comments
 (0)