Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 6ffe151

Browse files
Yaswanth/88385/pnl calculator console warning fix (#4173)
* refactor: adding hard lazy loading in cfd page * refactor: adding hard lazy loading in cfd page * refactor: adding hard lazy loading in cfd page * refactor: adding hard lazy loading in cfd page * refactor: plp margin calculator bug fix * refactor: plp margin calculator bug fix * refactor: hard lazy load in dmt5 page * refactor: hard lazy loader in dmt5 page * refactor: to fix console warning for pnl margin
1 parent 4a3edd2 commit 6ffe151

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

src/pages/dmt5/index.tsx

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
import Numbers from './_numbers'
1313
import WhatIsTrader from './_what-is-trader'
1414
import DHero from 'components/custom/_dhero-dmt5'
15+
import { DotLoader } from 'components/elements'
1516
import BackgroundPatternDMT5 from 'images/svg/dmt5/bg_banner_dmt5.svg'
1617
import BackgroundPatternDMT5_mobile from 'images/svg/dmt5/bg_banner_dmt5_mobile.svg'
1718
import Layout from 'components/layout/layout'
@@ -22,6 +23,7 @@ import { size } from 'themes/device'
2223
import { isBrowser } from 'common/utility'
2324
import { MetaAttributesType } from 'types/page.types'
2425
import { useIsRtl } from 'components/hooks/use-isrtl'
26+
import { useHandleLazyLoad } from 'components/hooks/use-handle-lazy-load'
2527

2628
const meta_attributes: MetaAttributesType = {
2729
og_title: localize('DMT5 | MetaTrader 5 | Deriv'),
@@ -46,7 +48,22 @@ const query = graphql`
4648
}
4749
}
4850
`
49-
51+
const target = '#gatsby-focus-wrapper'
52+
const options = {
53+
root: null,
54+
rootMargin: '0px',
55+
threshold: 0.7,
56+
}
57+
const lazy_components = (
58+
<>
59+
<WhyTrader fallback={<DotLoader />} />
60+
<StartTrader />
61+
<DownloadApp />
62+
<MarginCalculator />
63+
<Flexibility />
64+
<SwapFreeTrading fallback={<DotLoader />} />
65+
</>
66+
)
5067
const DMT5 = () => {
5168
const [is_mobile, setMobile] = useState(false)
5269
const data = useStaticQuery(query)
@@ -59,6 +76,7 @@ const DMT5 = () => {
5976
window.addEventListener('resize', handleResizeWindow)
6077
}, [])
6178

79+
const lazyTemplate = useHandleLazyLoad(lazy_components, target, options)
6280
const is_rtl = useIsRtl()
6381
const background = useMemo(() => {
6482
if (is_mobile) {
@@ -107,15 +125,9 @@ const DMT5 = () => {
107125
background={background}
108126
/>
109127
</Mobile>
110-
111128
<Numbers />
112129
<WhatIsTrader />
113-
<WhyTrader />
114-
<StartTrader />
115-
<DownloadApp />
116-
<MarginCalculator />
117-
<Flexibility />
118-
<SwapFreeTrading />
130+
{lazyTemplate}
119131
<DBanner
120132
background_pattern={
121133
is_mobile ? BackgroundPatternDMT5_mobile : BackgroundPatternDMT5

src/pages/trader-tools/common/_utility.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export const getPnlMarginCommon = (values, action) => {
8989
return toFixed(take_profit_level_formula)
9090
}
9191
case 'getStopLossLevelBuy': {
92-
const stop_loss_level_formula = assetPrice + [-stopLossAmount / (volume * contractSize)]
92+
const stop_loss_level_formula = assetPrice + -[stopLossAmount / (volume * contractSize)]
9393
return toFixed(stop_loss_level_formula)
9494
}
9595
case 'getTakeProfitLevelBuy': {

0 commit comments

Comments
 (0)