Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
33 lines
988 B
TypeScript
33 lines
988 B
TypeScript
import * as React from 'react';
|
|
import TextField from '@mui/material/TextField';
|
|
import Autocomplete from '@mui/material/Autocomplete';
|
|
|
|
const options = ['Option 1', 'Option 2'];
|
|
|
|
export default function ControllableStates() {
|
|
const [value, setValue] = React.useState<string | null>(options[0]);
|
|
const [inputValue, setInputValue] = React.useState('');
|
|
|
|
return (
|
|
<div>
|
|
<div>{`value: ${value !== null ? `'${value}'` : 'null'}`}</div>
|
|
<div>{`inputValue: '${inputValue}'`}</div>
|
|
<br />
|
|
<Autocomplete
|
|
value={value}
|
|
onChange={(event: any, newValue: string | null) => {
|
|
setValue(newValue);
|
|
}}
|
|
inputValue={inputValue}
|
|
onInputChange={(event, newInputValue) => {
|
|
setInputValue(newInputValue);
|
|
}}
|
|
id="controllable-states-demo"
|
|
options={options}
|
|
sx={{ width: 300 }}
|
|
renderInput={(params) => <TextField {...params} label="Controllable" />}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|