File tree Expand file tree Collapse file tree 2 files changed +15
-11
lines changed
features/remoteConfig/providers Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Original file line number Diff line number Diff line change 11import React from 'react'
2+ import BeatLoader from 'react-spinners/BeatLoader'
23import { useAsyncError } from 'src/hooks/useAsyncError'
34import { useGetRemoteConfig } from '../api/getRemoteConfig'
4- import BeatLoader from 'react-spinners/BeatLoader'
55
66type ConfigurationWrapperProps = {
77 children : React . ReactNode
@@ -11,6 +11,7 @@ export const ConfigurationWrapper = ({ children }: ConfigurationWrapperProps) =>
1111 const {
1212 isLoading,
1313 isError,
14+ error,
1415 data : remoteConfig ,
1516 } = useGetRemoteConfig ( {
1617 config : {
@@ -29,7 +30,9 @@ export const ConfigurationWrapper = ({ children }: ConfigurationWrapperProps) =>
2930 }
3031
3132 if ( isError || ! remoteConfig ) {
32- throwError ( 'Could not fetch configuration data, Make sure you are connected to the internet' )
33+ throwError (
34+ error ?? 'Could not fetch configuration data, Make sure you are connected to the internet.'
35+ )
3336 }
3437
3538 return < > { children } </ >
Original file line number Diff line number Diff line change 11import { useCallback , useState } from 'react'
22
33export const useAsyncError = ( ) => {
4- const [ , setError ] = useState ( )
5- return useCallback (
6- ( e : string ) => {
7- setError ( ( ) => {
8- throw e
9- } )
10- } ,
11- [ setError ]
12- )
4+ const [ , setError ] = useState < never > ( )
5+
6+ return useCallback ( ( err : unknown ) => {
7+ setError ( ( ) => {
8+ if ( err instanceof Error ) {
9+ throw err
10+ }
11+ throw new Error ( typeof err === 'string' ? err : JSON . stringify ( err ) )
12+ } )
13+ } , [ ] )
1314}
You can’t perform that action at this time.
0 commit comments