Skip to content

Commit b6ec72c

Browse files
committed
Split up useEffect concerns
1 parent d27ed34 commit b6ec72c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

example-apps/internal-knowledge-search/app-ui/src/components/SearchApplicationSettings.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,23 @@ const SearchApplicationSettings: React.FC = () => {
181181

182182
const [searchPersonaOptions, setSearchPersonaOptions] = useState(["admin"]);
183183

184+
// Populate personas dropdown options
184185
useEffect(()=>{
185186
(async()=>{
186187
const fetchedPersonas = await fetchPersonaOptions()
187188
setSearchPersonaOptions(fetchedPersonas)
189+
})()
190+
},[])
191+
192+
// Ensure we have an API key and override the "missing" default
193+
useEffect(()=>{
194+
(async()=>{
188195
if (searchPersonaAPIKey == "missing") {
189196
const createdAPIKey = await createPersonaAPIKey(searchPersona)
190197
updateSearchPersonaAPIKey(createdAPIKey)
191198
}
192199
})()
193-
},[])
200+
}, [])
194201

195202
const [isOpen, setIsOpen] = useState(false);
196203

0 commit comments

Comments
 (0)