Refactored the code.
This commit is contained in:
1 parent
a7a8bb2ea8
commit
3376186ff3
2 files changed
+3
-4
No files matched your search
@@ -55,8 +55,8 @@ const Select = ({
|
|||||||
truncate = false,
|
truncate = false,
|
||||||
maxStringLength = 10,
|
maxStringLength = 10,
|
||||||
}) => {
|
}) => {
|
||||||
const [maxLength, setMaxLength] = useState(0); // Initially set maxLength to 0
|
const [maxLength, setMaxLength] = useState(0);
|
||||||
const selectRef = useRef(null); // Reference for the Select container
|
const selectRef = useRef(null);
|
||||||
|
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const itemStyles = {
|
const itemStyles = {
|
||||||
@@ -85,7 +85,6 @@ const Select = ({
|
|||||||
};
|
};
|
||||||
}, [maxStringLength, truncate]);
|
}, [maxStringLength, truncate]);
|
||||||
|
|
||||||
// Get the selected item's name
|
|
||||||
const selectedItemName = truncate
|
const selectedItemName = truncate
|
||||||
? items.find((item) => item._id === value)?.name // Only calculate if truncate is true
|
? items.find((item) => item._id === value)?.name // Only calculate if truncate is true
|
||||||
: null;
|
: null;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// src/utils/truncateUtils.js
|
// src/utils/truncateUtils.js
|
||||||
import { isEmpty } from "./stringUtils"; // assuming you have the stringUtils file
|
import { isEmpty } from "./stringUtils";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility function to render a truncated value with an optional title.
|
* Utility function to render a truncated value with an optional title.
|
||||||
|
|||||||
Reference in new issue
Block a user