yangdx commited on
Commit
920a7ad
·
1 Parent(s): d98214a

Refactor AsyncSearch component for better key management

Browse files
lightrag_webui/src/components/ui/AsyncSearch.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { useState, useEffect, useCallback } from 'react'
2
  import { Loader2 } from 'lucide-react'
3
  import { useDebounce } from '@/hooks/useDebounce'
4
 
@@ -204,7 +204,7 @@ export function AsyncSearch<T>({
204
  ))}
205
  <CommandGroup>
206
  {options.map((option, idx) => (
207
- <>
208
  <CommandItem
209
  key={getOptionValue(option) + `${idx}`}
210
  value={getOptionValue(option)}
@@ -215,9 +215,9 @@ export function AsyncSearch<T>({
215
  {renderOption(option)}
216
  </CommandItem>
217
  {idx !== options.length - 1 && (
218
- <div key={idx} className="bg-foreground/10 h-[1px]" />
219
  )}
220
- </>
221
  ))}
222
  </CommandGroup>
223
  </CommandList>
 
1
+ import React, { useState, useEffect, useCallback } from 'react'
2
  import { Loader2 } from 'lucide-react'
3
  import { useDebounce } from '@/hooks/useDebounce'
4
 
 
204
  ))}
205
  <CommandGroup>
206
  {options.map((option, idx) => (
207
+ <React.Fragment key={getOptionValue(option) + `-fragment-${idx}`}>
208
  <CommandItem
209
  key={getOptionValue(option) + `${idx}`}
210
  value={getOptionValue(option)}
 
215
  {renderOption(option)}
216
  </CommandItem>
217
  {idx !== options.length - 1 && (
218
+ <div key={`divider-${idx}`} className="bg-foreground/10 h-[1px]" />
219
  )}
220
+ </React.Fragment>
221
  ))}
222
  </CommandGroup>
223
  </CommandList>