+ const [showMoreOptions, setShowMoreOptions] = useAtom(
+ moreOptionsAtom,
+ jotaiScope,
+ );
+
+ const alwaysVisibleOptions = React.useMemo(
+ () => options.slice(0, numberOfOptionsToAlwaysShow),
+ [options, numberOfOptionsToAlwaysShow],
+ );
+ const moreOptions = React.useMemo(
+ () => options.slice(numberOfOptionsToAlwaysShow),
+ [options, numberOfOptionsToAlwaysShow],
+ );
+
+ useEffect(() => {
+ if (!alwaysVisibleOptions.some((option) => option.value === value)) {
+ setShowMoreOptions(true);
+ }
+ }, [value, alwaysVisibleOptions, setShowMoreOptions]);
+
+ const renderOptions = (options: Option
[]) => {
+ return (
+
{options.map((option, i) => (
))}
-