@@ -65,17 +65,15 @@ export function Provider({ children, ...propsSettings }: Props): ReactElement {
65
65
const propsProviderUrl =
66
66
localStorage . getItem ( LocalStorageKeys . providerUrl ) || propsSettings . defaultRpcUrl || DEFAULT_RPC_URL
67
67
68
- const [ apiUrl , setApiUrl ] = useState < string > ( initialValues . apiUrl )
68
+ const [ apiUrl , setApiUrl ] = useState < string > (
69
+ sessionStorage . getItem ( 'api_host' ) ?? propsSettings . beeApiUrl ?? initialValues . apiUrl ,
70
+ )
69
71
const [ beeApi , setBeeApi ] = useState < Bee | null > ( null )
70
72
const [ desktopApiKey , setDesktopApiKey ] = useState < string > ( initialValues . desktopApiKey )
71
73
const [ rpcProviderUrl , setRpcProviderUrl ] = useState ( propsProviderUrl )
72
74
const [ rpcProvider , setRpcProvider ] = useState ( new providers . JsonRpcProvider ( propsProviderUrl ) )
73
75
const { config, isLoading, error } = useGetBeeConfig ( desktopUrl )
74
76
75
- const url = makeHttpUrl (
76
- config ?. [ 'api-addr' ] ?? sessionStorage . getItem ( 'api_host' ) ?? propsSettings . beeApiUrl ?? apiUrl ,
77
- )
78
-
79
77
useEffect ( ( ) => {
80
78
const urlSearchParams = new URLSearchParams ( window . location . search )
81
79
const newApiKey = urlSearchParams . get ( 'v' )
@@ -88,18 +86,19 @@ export function Provider({ children, ...propsSettings }: Props): ReactElement {
88
86
} , [ ] )
89
87
90
88
useEffect ( ( ) => {
89
+ const url = makeHttpUrl ( config ?. [ 'api-addr' ] ?? apiUrl )
91
90
try {
92
91
setBeeApi ( new Bee ( url ) )
93
92
sessionStorage . setItem ( 'api_host' , url )
94
93
} catch ( e ) {
95
94
setBeeApi ( null )
96
95
}
97
- } , [ url ] )
96
+ } , [ config , apiUrl ] )
98
97
99
98
return (
100
99
< Context . Provider
101
100
value = { {
102
- apiUrl : url ,
101
+ apiUrl,
103
102
beeApi,
104
103
setApiUrl,
105
104
lockedApiSettings : Boolean ( propsSettings . lockedApiSettings ) ,
0 commit comments