Skip to content

Commit

Permalink
fix env on app initializing
Browse files Browse the repository at this point in the history
  • Loading branch information
CiprianDraghici committed Nov 29, 2023
1 parent 65e1680 commit 5a403bc
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/context/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import {
useReducer,
useContext,
PropsWithChildren,
useEffect,
} from 'react';
import { EnvironmentsEnum } from '@multiversx/sdk-dapp/types';
import { DappProvider } from '@multiversx/sdk-dapp/wrappers';
import { PERSISTED_NETWORK_KEY } from 'localConstants';
import { ActionTypeEnum, DispatchType, reducer } from './reducer';
import { DispatchType, reducer } from './reducer';
import { StateType, initializer } from './state';

const Context = createContext<StateType | undefined>(undefined);
Expand All @@ -23,16 +22,9 @@ const ContextProvider = (props: PropsWithChildren) => {

const [state, dispatch] = useReducer(reducer, {
...initializer,
dappEnvironment: initializer.dappEnvironment,
dappEnvironment: env,
});

useEffect(() => {
dispatch({
type: ActionTypeEnum.switchDappEnvironment,
dappEnvironment: env,
});
}, [env]);

return (
<Context.Provider value={state}>
<DappProvider
Expand Down

0 comments on commit 5a403bc

Please sign in to comment.