Added prop types to the dropdown feature.
This commit is contained in:
1 parent
f98ee170f6
commit
e305d78722
2 files changed
+13
-1
No files matched your search
@@ -42,3 +42,4 @@ function App() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default App
|
export default App
|
||||||
|
|
||||||
+12
-1
@@ -1,4 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import Autocomplete from '@mui/material/Autocomplete';
|
import Autocomplete from '@mui/material/Autocomplete';
|
||||||
import TextField from '@mui/material/TextField';
|
import TextField from '@mui/material/TextField';
|
||||||
|
|
||||||
@@ -7,7 +9,7 @@ const DropDown = ({ id, label, options, onChange, value }) => {
|
|||||||
<Autocomplete
|
<Autocomplete
|
||||||
id={id}
|
id={id}
|
||||||
options={options}
|
options={options}
|
||||||
getOptionLabel={(option) => option.name} // Assuming each team member object has a 'name' property
|
getOptionLabel={(option) => option.name}
|
||||||
value={value}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
renderInput={(params) => <TextField {...params} label={label} />}
|
renderInput={(params) => <TextField {...params} label={label} />}
|
||||||
@@ -15,4 +17,13 @@ const DropDown = ({ id, label, options, onChange, value }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Define PropTypes for DropDown component
|
||||||
|
DropDown.propTypes = {
|
||||||
|
id: PropTypes.string.isRequired,
|
||||||
|
label: PropTypes.string.isRequired,
|
||||||
|
options: PropTypes.array.isRequired,
|
||||||
|
onChange: PropTypes.func.isRequired,
|
||||||
|
value: PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
export default DropDown;
|
export default DropDown;
|
||||||
Reference in new issue
Block a user