-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathApp.jsx
40 lines (36 loc) · 1.1 KB
/
App.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import SemanticAutocomplete from "../../src/SemanticAutocomplete";
import { TextField, ListItem, ListItemText, List } from "@mui/material";
import React, { useContext, useMemo } from 'react'
const SemanticAutocompleteMemoized = React.memo(SemanticAutocomplete)
import { SortedOptionsContext } from './context.jsx'
import jsonData from './data.json';
function App() {
const options = useMemo(() => jsonData, []);
const { sortedOptions, setSortedOptions } = useContext(SortedOptionsContext);
const ResultsList = () => {
return (
<List>
{sortedOptions.map(op => (
<ListItem key={op.label + op.value}>
<ListItemText primary={op.label} />
</ListItem>
))}
</List>
);
}
return (
<div>
<SemanticAutocompleteMemoized
freeSolo
options={options}
onResult={setSortedOptions}
renderInput={(params) => <TextField {...params} placeholder="What are embeddings?" />}
model="TaylorAI/gte-tiny"
open={false}
popupIcon={null}
/>
<ResultsList />
</div>
);
}
export default App;