@c-rex/contexts 0.1.16 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c-rex/contexts",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src"
@@ -10,7 +10,6 @@ import { useLanguageStore } from '@c-rex/components/language-store'
10
10
  type AppConfigContextType = {
11
11
  error: Error | null
12
12
  configs: CookiesConfigs
13
- loading: boolean
14
13
  packageID: string | null
15
14
  articleLang: string | null
16
15
  availableVersions: AvailableVersionsInterface[] | null
@@ -37,7 +36,6 @@ export const AppConfigProvider = ({
37
36
  }: AppConfigProviderProps) => {
38
37
 
39
38
  const [error, setError] = useState<Error | null>(null)
40
- const [loading, setLoading] = useState(true)
41
39
  const [packageID, setPackageID] = useState<string | null>(null)
42
40
  const [articleLang, setArticleLang] = useState<string | null>(null)
43
41
  const [availableVersions, setAvailableVersions] = useState<AvailableVersionsInterface[] | null>(null)
@@ -89,7 +87,6 @@ export const AppConfigProvider = ({
89
87
 
90
88
  const load = async () => {
91
89
  try {
92
- setLoading(true)
93
90
  await manageToken()
94
91
  setError(null)
95
92
  } catch (err) {
@@ -98,25 +95,16 @@ export const AppConfigProvider = ({
98
95
  message: `config-provider.load error: ${err}`
99
96
  });
100
97
  setError(err as Error)
101
- } finally {
102
- setLoading(false)
103
98
  }
104
99
  }
105
100
 
106
101
  load()
107
102
  }, [])
108
103
 
109
- const loadingComp = (
110
- <div className="flex items-center justify-center min-h-screen bg-white">
111
- <div className="animate-spin rounded-full h-12 w-12 border-2 border-gray-300 border-t-gray-950" />
112
- </div>
113
- )
114
-
115
104
  return (
116
105
  <AppConfigContext.Provider
117
106
  value={{
118
107
  configs: initialConfig,
119
- loading,
120
108
  error,
121
109
  availableVersions,
122
110
  packageID,
@@ -126,7 +114,7 @@ export const AppConfigProvider = ({
126
114
  setPackageID
127
115
  }}
128
116
  >
129
- {loading ? loadingComp : children}
117
+ {children}
130
118
  </AppConfigContext.Provider>
131
119
  )
132
120
  }
package/src/search.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client"
2
2
 
3
- import { createContext, useContext, ReactNode, useState } from "react";
3
+ import { createContext, useContext, ReactNode, useState, useEffect } from "react";
4
4
  import { Loading } from "@c-rex/components/loading";
5
5
 
6
6
  type SearchContextProps = {
@@ -11,11 +11,16 @@ type SearchContextProps = {
11
11
  const SearchContext = createContext<SearchContextProps | undefined>(undefined);
12
12
 
13
13
  export const SearchProvider = ({ children }: { children: ReactNode }) => {
14
- const [loading, setLoading] = useState<boolean>(true)
14
+ const [mounted, setMounted] = useState(false)
15
+ const [loading, setLoading] = useState<boolean>(false)
16
+
17
+ useEffect(() => {
18
+ setMounted(true)
19
+ }, [])
15
20
 
16
21
  return (
17
22
  <SearchContext.Provider value={{ setLoading, loading }}>
18
- {loading && <Loading opacity />}
23
+ {mounted && loading && <Loading opacity />}
19
24
 
20
25
  {children}
21
26
  </SearchContext.Provider>