Skip to content

Commit

Permalink
Merge pull request #896 from multiversx/development
Browse files Browse the repository at this point in the history
2.19.4
  • Loading branch information
arhtudormorar authored Aug 28, 2023
2 parents 5737d5e + a609bb1 commit 78c1c2b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ All notable changes will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [[v2.19.4]](https://github.com/multiversx/mx-sdk-dapp/pull/896)] - 2023-08-28
- [Memoize dappConfig in order to not trigger initializeApp on every DappProvider rerender](https://github.com/multiversx/mx-sdk-dapp/pull/894)
## [[v2.19.3]](https://github.com/multiversx/mx-sdk-dapp/pull/890)] - 2023-08-21
- [Added `DataTestIdsEnum` to `data-testid` HTML tags](https://github.com/multiversx/mx-sdk-dapp/pull/889)
- [Added `addOriginToLocationPath` helper to parse redirect URLs](https://github.com/multiversx/mx-sdk-dapp/pull/888)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-dapp",
"version": "2.19.4-alpha",
"version": "2.19.4",
"description": "A library to hold the main logic for a dapp on the MultiversX blockchain",
"author": "MultiversX",
"license": "GPL-3.0-or-later",
Expand Down
11 changes: 7 additions & 4 deletions src/wrappers/AppInitializer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from 'react';
import { useEffect, useMemo, useState } from 'react';
import { Address } from '@multiversx/sdk-core/out';
import { getServerConfiguration } from 'apiCalls';
import { fallbackNetworkConfigurations } from 'constants/network';
Expand Down Expand Up @@ -35,7 +35,10 @@ export const useAppInitializer = ({
const [initialized, setInitialized] = useState(false);
const account = useGetAccountInfo();
const isLoginSessionInvalid = useSelector(isLoginSessionInvalidSelector);
const logoutRoute = dappConfig?.logoutRoute;

// memoize dappConfig to avoid rerendering of AppInitializer
const memoizedDappConfig = useMemo(() => dappConfig, []);
const logoutRoute = memoizedDappConfig?.logoutRoute;

const { address, publicKey } = account;
const dispatch = useDispatch();
Expand Down Expand Up @@ -72,7 +75,7 @@ export const useAppInitializer = ({
}

async function initializeApp() {
dispatch(setDappConfig(dappConfig));
dispatch(setDappConfig(memoizedDappConfig));
dispatch(setLogoutRoute(logoutRoute));
await initializeNetwork();

Expand All @@ -90,7 +93,7 @@ export const useAppInitializer = ({

useEffect(() => {
initializeApp();
}, [customNetworkConfig, environment, dappConfig]);
}, [customNetworkConfig, environment, memoizedDappConfig]);

useEffect(() => {
if (account.address && isLoginSessionInvalid) {
Expand Down

0 comments on commit 78c1c2b

Please sign in to comment.