I am struggling to work out something that is likely very simply. My parent component is a Search widget, which needs to use Filters defined in a separate Drawer component. Currently the user can type in a search query, which calls an API, and it needs to filter the results based on selectors form the drawer component. However, I cannot link the parent and child to make this happen!!
The parent component (which includes the '' component within):
function SuburbSearch(props: Props) {
const classes = useStyles();
const [value, setValue] = React.useState<App.Suburb | null>(null);
const [inputValue, setInputValue] = React.useState('');
...
return (
<Autocomplete
id="search"
getOptionLabel={(option) => (typeof option === 'string' ? option : option.name + ' ' + option.state)}
filterOptions={(x) => x}
options={options}
...
...
renderInput={(params) => (
<TextField
{...params}
label="Search for a suburb"
...,
startAdornment: (
<InputAdornment position="start">
<Filters></Filters>
</InputAdornment>
),
endAdornment: (
<React.Fragment>
{loading ? <CircularProgress color="inherit" size={20} /> : null}
{params.InputProps.endAdornment}
</React.Fragment>
),
}}
fullWidth
/>
)}
The child component (this is the 'Filter'):
export default function Filters() {
const classes = useStyles();
const [state, setState] = useState(false);
const [dollar, setDollars] = useState<number[]>([0, 20000000]);
const [type, setType] = React.useState<string | null>('all');
...
const list = (anchor: Anchor) => (
<div className={classes.root}
role="presentation" /*onClick={toggleDrawer(false)} onKeyDown={toggleDrawer(false)}/*/>
<Grid className={classes.main} container spacing={2}>
<Grid className={classes.row} item xs={1} md={2} />
<Grid className={classes.row} item xs={10} md={8}>
<Typography className={classes.header} align='center' gutterBottom>
Property Type
</Typography>
<ToggleButtonGroup value={type} onChange={handleTypeChange} exclusive>
<ToggleButton value="all" >All</ToggleButton>
<ToggleButton value="some" >Some</ToggleButton>
</ToggleButtonGroup>
</Grid>
...
</Grid>
</div>
}