Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // https://mui.com/material-ui/react-select/
- import React, { useState, useEffect } from 'react'
- import { FormControl, InputLabel, Select, MenuItem } from '@mui/material'
- export default function App() {
- const [age, setAge] = useState('')
- const handleChange = (event) => {
- setAge(event.target.value)
- }
- useEffect(() => {
- // установить значение через секунду после загрузки страницы
- setTimeout(() => {
- setAge(10)
- }, 1000)
- }, [])
- return (
- <FormControl fullWidth>
- <InputLabel id="demo-simple-select-label">Age</InputLabel>
- <Select
- labelId="demo-simple-select-label"
- id="demo-simple-select"
- value={age}
- label="Age"
- onChange={handleChange}
- >
- <MenuItem value={10}>Ten</MenuItem>
- <MenuItem value={20}>Twenty</MenuItem>
- <MenuItem value={30}>Thirty</MenuItem>
- </Select>
- </FormControl>
- )
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement