I'm using React Typescript and have a Autocomplete Material UI component. I'm trying to get query suggestions into Autocomplete component.
My graphql queries looks like this:
Query Definition:
import gql from 'graphql-tag';
import {useQuery} from 'react-apollo';
const TODOS = gql`
query todos($id: ID!) {
todo(id: $id) {
id
name
}
}
`;
Query Initialization:
const { loading, error, data } = useQuery(TODOS, {
variables: { id }
});
I want to create a autocomplete component which will take a numeric value from the textfield component and pass it on to the autocomplete material ui component?
My numeric component looks like this:
<TextField
id="filled-number"
label="Number"
type="number"
InputLabelProps={{
shrink: true,
}}
variant="filled"
/>
Autocomplete component:
<Autocomplete
id="combo-box-demo"
options={idx.name}
getOptionLabel={(option: {name: string}) => option.name}
style={{width: 300}}
renderInput={params => (
<TextField
{...params}
label="Combo box"
variant="outlined"
/>
So it should set id from the number textfield component and then pass the query to the autocomplete component?