Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to get the value of AutoCompelet Component in MUI

const users = [
        { userName: 'bob',  age: 20, message:[...] },
        { userName: 'jane', age: 43, message:[...] },
        { userName: 'joe',  age: 88, message:[...] },
    }

    <Autocomplete
        id="combo-box-demo"
        options={users}
        getOptionLabel={(user) => user.userName }
        getOptionSelected={(option, value) => option.userName === value.userName }
        onChange={(event, newValue) => {
            this.setValue(newValue);
        }}
 
        // more code

    setValue = (newValue) => {
        console.log(newValue); //  { userName: 'jane', age: 43, message:[...] }
    }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #AutoCompelet #Component #MUI
ADD COMMENT
Topic
Name
3+9 =