我正在努力解决一些可能非常简单的问题。我的父组件是一个 Search 小部件,它需要使用单独的 Drawer 组件中定义的过滤器。目前用户可以输入一个搜索查询,它调用一个API,它需要根据抽屉组件的选择器过滤结果。但是,我无法链接父母和孩子来实现这一点!!
父组件(包括其中的 '' 组件):
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} /> …Run Code Online (Sandbox Code Playgroud)