Added prop types to the dropdown feature.

This commit is contained in:
M M
2024-05-05 15:40:18 -07:00
parent f98ee170f6
commit e305d78722
2 changed files with 13 additions and 1 deletions
+1
View File
@@ -42,3 +42,4 @@ function App() {
}
export default App
+12 -1
View File
@@ -1,4 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import Autocomplete from '@mui/material/Autocomplete';
import TextField from '@mui/material/TextField';
@@ -7,7 +9,7 @@ const DropDown = ({ id, label, options, onChange, value }) => {
<Autocomplete
id={id}
options={options}
getOptionLabel={(option) => option.name} // Assuming each team member object has a 'name' property
getOptionLabel={(option) => option.name}
value={value}
onChange={onChange}
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;