Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Biz/dj 2800 add async options pagination in connect react #15248

Merged

Conversation

bzwrk
Copy link
Contributor

@bzwrk bzwrk commented Jan 9, 2025

WHY

Summary by CodeRabbit

  • New Features

    • Added "Load More" functionality to option selection components.
    • Introduced a new LoadMoreButton component for improved user interaction.
  • Dependencies

    • Updated @pipedream/sdk to version ^1.1.4.
    • Updated @pipedream/connect-react to version 1.0.0-preview.19.
  • Improvements

    • Enhanced remote options loading with pagination support.
    • Added support for conditional loading of additional options in select components.
    • Expanded customization options with the inclusion of the LoadMoreButton in the component library.

Copy link

linear bot commented Jan 9, 2025

Copy link

vercel bot commented Jan 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Jan 15, 2025 8:11pm
pipedream-docs ⬜️ Ignored (Inspect) Jan 15, 2025 8:11pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Jan 15, 2025 8:11pm

Copy link
Contributor

coderabbitai bot commented Jan 9, 2025

Walkthrough

This pull request introduces updates to the @pipedream/connect-react package, enhancing the ControlSelect component with pagination and load more functionality. Changes include the addition of new props and state management in the RemoteOptionsContainer, the creation of a new LoadMoreButton component, and updates to the customization context to support the new button. The package version has been incremented, and a dependency in the NextJS example project has been updated.

Changes

File Change Summary
packages/connect-react/examples/nextjs/package.json Updated @pipedream/sdk dependency from ^1.0.6 to ^1.1.4
packages/connect-react/package.json Bumped package version from 1.0.0-preview.18 to 1.0.0-preview.19
packages/connect-react/src/components/ControlSelect.tsx Added new props for load more functionality, updated type definitions
packages/connect-react/src/components/LoadMoreButton.tsx New component for rendering a load more button with customization
packages/connect-react/src/components/RemoteOptionsContainer.tsx Added pagination-related state variables and methods for loading more options
packages/connect-react/src/hooks/customization-context.tsx Integrated LoadMoreButton into default components and customization props
components/bluesnap/bluesnap.app.mjs Added a newline at the end of the file
components/grafana/grafana.app.mjs Added a newline at the end of the file
components/polymer_co/polymer_co.app.mjs Added a newline at the end of the file
components/shutterstock/shutterstock.app.mjs Added a newline at the end of the file

Possibly related PRs

Suggested labels

enhancement, docs, dependencies, ai-assisted

Suggested reviewers

  • jverce

Poem

🐰 Hop, hop, loading more with glee,
Options dancing, setting data free!
Pagination's magic, a button so bright,
Connecting worlds with CodeRabbit's might!
Scroll on, brave user, explore without end! 🚀


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6fbcc4b and 7f5d2fd.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • components/bluesnap/bluesnap.app.mjs (1 hunks)
  • components/grafana/grafana.app.mjs (1 hunks)
  • components/polymer_co/polymer_co.app.mjs (1 hunks)
  • components/shutterstock/shutterstock.app.mjs (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • components/grafana/grafana.app.mjs
  • components/bluesnap/bluesnap.app.mjs
  • components/shutterstock/shutterstock.app.mjs
  • components/polymer_co/polymer_co.app.mjs
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: pnpm publish
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
packages/connect-react/src/components/RemoteOptionsContainer.tsx (1)

Line range hint 122-133: Improve canLoadMore logic.

The setCanLoadMore is always set to true when options exist, but it should consider if there are more pages available.

-        setCanLoadMore(true)
+        setCanLoadMore(!!res.context)
         return options;
       }
       if (stringOptions?.length) {
         const options = [];
         for (const stringOption of stringOptions) {
           options.push({
             label: stringOption,
             value: stringOption,
           });
         }
-        setCanLoadMore(true)
+        setCanLoadMore(!!res.context)
         return options;
       }
🧹 Nitpick comments (4)
packages/connect-react/src/components/LoadMoreButton.tsx (2)

4-7: Consider enhancing ButtonProps interface.

The props interface could be improved to support loading states and accessibility.

 export type ButtonProps = {
   enabled: boolean;
   onClick: () => void;
+  isLoading?: boolean;
+  'aria-label'?: string;
 };

31-33: Add aria-label for better accessibility.

The "Load More" button should have an aria-label for better screen reader support.

-    <button disabled={!enabled} onClick={onClick} type="button" {...getProps("loadMoreButton", baseStyles, props)}>
+    <button 
+      disabled={!enabled} 
+      onClick={onClick} 
+      type="button" 
+      aria-label="Load more items"
+      {...getProps("loadMoreButton", baseStyles, props)}
+    >
      Load More
     </button>
packages/connect-react/src/components/ControlSelect.tsx (1)

Line range hint 137-139: Improve error message for unhandled option type.

The error message could be more descriptive to help with debugging.

-            throw new Error("unhandled option type"); // TODO
+            throw new Error(`Unhandled option type. Expected array or object with 'value' property, received: ${typeof o}`);
packages/connect-react/src/components/RemoteOptionsContainer.tsx (1)

42-48: Simplify state management by combining related states.

The page, context, and pageable states could be combined into a single state object for better maintainability.

-  const [page, setPage] = useState<number>(0);
-  const [context, setContext] = useState<never | undefined>(undefined);
-  const [pageable, setPageable] = useState({
-    page: 0,
-    prevContext: undefined,
-  })
+  const [pagination, setPagination] = useState<{
+    currentPage: number;
+    nextPage: number;
+    context: never | undefined;
+  }>({
+    currentPage: 0,
+    nextPage: 0,
+    context: undefined,
+  });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b76304 and 916354a.

⛔ Files ignored due to path filters (2)
  • packages/connect-react/examples/nextjs/package-lock.json is excluded by !**/package-lock.json
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • packages/connect-react/examples/nextjs/package.json (1 hunks)
  • packages/connect-react/package.json (1 hunks)
  • packages/connect-react/src/components/ControlSelect.tsx (5 hunks)
  • packages/connect-react/src/components/LoadMoreButton.tsx (1 hunks)
  • packages/connect-react/src/components/RemoteOptionsContainer.tsx (6 hunks)
  • packages/connect-react/src/hooks/customization-context.tsx (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/connect-react/package.json
🧰 Additional context used
🪛 eslint
packages/connect-react/src/components/ControlSelect.tsx

[error] 79-79: 'children' is missing in props validation

(react/prop-types)


[error] 94-94: 'components' is missing in props validation

(react/prop-types)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: pnpm publish
  • GitHub Check: Lint Code Base
🔇 Additional comments (3)
packages/connect-react/src/hooks/customization-context.tsx (1)

36-43: LGTM! Clean integration of LoadMoreButton.

The LoadMoreButton is correctly integrated into the customization context.

packages/connect-react/examples/nextjs/package.json (2)

10-10: Verify SDK version compatibility with new pagination features

The SDK version has been updated to ^1.1.4. Let's verify this version includes the required features for async options pagination.

✅ Verification successful

Version update is appropriate for example project

The update from ^1.0.6 to ^1.1.4 follows semantic versioning principles and represents a compatible change. As an example project, it's good practice to use the latest stable version of dependencies.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check SDK changelog and package.json for pagination-related changes

# Check SDK package for pagination-related exports
fd "package.json" --exec rg -A 5 "pagination|async.*options" {}

# Look for pagination-related changes in recent commits
git log -n 10 --oneline --grep="pagination" --grep="async.*options"

Length of output: 65


Script:

#!/bin/bash
# Search for SDK imports and pagination-related code
rg "@pipedream/sdk" -A 5

# Search for pagination-related code in the example project
rg -t js -t tsx "async.*options|pagination" packages/connect-react/examples/nextjs/

Length of output: 46273


Script:

#!/bin/bash
# Search for ControlSelect implementation and pagination-related code
ast-grep --pattern 'export function ControlSelect() {
  $$$
}'

# Search for async options or pagination in component props
rg -t ts -t tsx "async.*options|pagination" packages/connect-react/src/

Length of output: 166


12-13: Verify React RC version compatibility

The project uses a specific React RC version (19.0.0-rc-66855b96-20241106). Please confirm if this is intentional or if we should use a stable version instead.

✅ Verification successful

RC version usage is intentionally isolated to NextJS example

The React RC version is only used in the NextJS example, while the rest of the codebase uses stable versions. This isolation suggests it's an intentional choice for testing or demonstrating compatibility with React 19, and doesn't affect the main package or other examples.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for React version consistency across the monorepo

# Find all package.json files and check React versions
fd "package.json" --exec rg "react.*19\.0\.0-rc-66855b96-20241106" {}

Length of output: 162


Script:

#!/bin/bash
# Show all React version declarations across package.json files
echo "=== React versions across package.json files ==="
fd "package.json" --exec rg '"react": ".*"' {}
fd "package.json" --exec rg '"react-dom": ".*"' {}

echo -e "\n=== Checking documentation for React version requirements ==="
rg -i "react.*version|react.*requirement" -g "!package*.json" -g "*.md"

Length of output: 659

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (1)
packages/connect-react/src/components/ControlSelect.tsx (1)

78-90: 🛠️ Refactor suggestion

Move LoadMore component outside and add proper type definitions.

The inline LoadMore component has several issues:

  1. Missing proper type definitions
  2. ESLint warnings being suppressed
  3. Defined within render which creates a new component on each render
+ type LoadMoreProps = {
+   children: React.ReactNode;
+   innerProps?: Record<string, unknown>;
+ } & React.ComponentProps<typeof components.MenuList>;
+
+ const LoadMore = ({
+   children,
+   innerProps,
+   ...props
+ }: LoadMoreProps) => {
-const LoadMore = ({
-  // eslint-disable-next-line react/prop-types
-  children, ...props
-}) => {

Also, consider moving this component to a separate file for better maintainability.

🧹 Nitpick comments (4)
packages/connect-react/src/components/LoadMoreButton.tsx (1)

4-6: Enhance ButtonProps interface for better flexibility and accessibility.

The current props interface is too minimal. Consider adding common button props and accessibility attributes.

 export type ButtonProps = {
   onChange: () => void;
+  isLoading?: boolean;
+  disabled?: boolean;
+  className?: string;
+  'aria-label'?: string;
 };
packages/connect-react/src/components/ControlSelect.tsx (1)

92-99: Avoid mutating props object directly.

The components object is being modified directly. Create a new object instead.

- const props = select.getProps("controlSelect", baseSelectProps)
- if (showLoadMoreButton) {
-   props.components = {
-     // eslint-disable-next-line react/prop-types
-     ...props.components,
-     MenuList: LoadMore,
-   }
- }
+ const props = {
+   ...select.getProps("controlSelect", baseSelectProps),
+   ...(showLoadMoreButton && {
+     components: {
+       ...select.getProps("controlSelect", baseSelectProps).components,
+       MenuList: LoadMore,
+     }
+   })
+ };
packages/connect-react/src/components/RemoteOptionsContainer.tsx (2)

135-144: Handle edge cases in data accumulation.

The data accumulation logic needs to handle edge cases and prevent duplicates.

  const data = [
    ...pageable.data,
-   ..._options,
+   ..._options.filter(newOption => 
+     !pageable.data.some(existingOption => 
+       existingOption.value === newOption.value
+     )
+   ),
  ]
  setPageable({
    page: page + 1,
    prevContext: res.context,
    data,
  })

149-151: Improve loading state handling in showLoadMoreButton.

The showLoadMoreButton function should consider the isLoadingMore state.

  const showLoadMoreButton = () => {
-   return !isFetching && !error && canLoadMore()
+   return !isFetching && !isLoadingMore && !error && canLoadMore()
  }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 916354a and df5f788.

⛔ Files ignored due to path filters (1)
  • packages/connect-react/examples/nextjs/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • packages/connect-react/src/components/ControlSelect.tsx (5 hunks)
  • packages/connect-react/src/components/LoadMoreButton.tsx (1 hunks)
  • packages/connect-react/src/components/RemoteOptionsContainer.tsx (6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: pnpm publish
  • GitHub Check: Lint Code Base

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
packages/connect-react/src/components/RemoteOptionsContainer.tsx (1)

85-92: ⚠️ Potential issue

Add error handling and prevent potential race conditions.

The onLoadMore function needs error handling and should prevent multiple concurrent calls.

+ const [isLoadingMore, setIsLoadingMore] = useState(false);
+
- const onLoadMore = () => {
+ const onLoadMore = async () => {
+   if (isLoadingMore) return;
+   try {
+     setIsLoadingMore(true);
+     setPageable(prev => ({
+       ...prev,
+       prevContext: {},
+     }));
+     await refetch();
+   } catch (error) {
+     setError({
+       name: "Error",
+       message: "Failed to load more items",
+     });
+   } finally {
+     setIsLoadingMore(false);
+   }
  }
🧹 Nitpick comments (1)
packages/connect-react/src/components/RemoteOptionsContainer.tsx (1)

170-172: Optimize showLoadMoreButton with useMemo.

Consider memoizing this function to prevent unnecessary re-renders.

- const showLoadMoreButton = () => {
+ const showLoadMoreButton = useMemo(() => {
    return !isFetching && !error && canLoadMore
- }
+ }, [isFetching, error, canLoadMore]);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between df5f788 and f024e09.

📒 Files selected for processing (1)
  • packages/connect-react/src/components/RemoteOptionsContainer.tsx (6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: pnpm publish
  • GitHub Check: Lint Code Base
🔇 Additional comments (3)
packages/connect-react/src/components/RemoteOptionsContainer.tsx (3)

32-56: 🛠️ Refactor suggestion

Consolidate state management and improve type safety.

The current implementation has several state management issues:

  1. page and context states duplicate data already present in pageable
  2. context type (never | undefined) is problematic
  3. Multiple states could be consolidated for better maintainability

Consider consolidating the states and improving type safety:

+ type Option = {
+   label: string;
+   value: string | number;
+ };
+
+ interface PageableState {
+   page: number;
+   prevContext: Record<string, unknown>;
+   data: Option[];
+   values: Set<string | number>;
+   canLoadMore: boolean;
+ }
+
- const [page, setPage] = useState<number>(0);
- const [canLoadMore, setCanLoadMore] = useState<boolean>(true);
- const [context, setContext] = useState<never | undefined>(undefined);
- const [pageable, setPageable] = useState({
-   page: 0,
-   prevContext: {},
-   data: [],
-   values: new Set(),
- });
+ const [pageable, setPageable] = useState<PageableState>({
+   page: 0,
+   prevContext: {},
+   data: [],
+   values: new Set(),
+   canLoadMore: true,
+ });

Likely invalid or redundant comment.


Line range hint 123-165: Improve type safety and simplify options handling logic.

The options handling logic needs improvement in several areas:

  1. Missing TypeScript types for API response
  2. Complex nested conditions
  3. Growing Set of values without cleanup

Consider this refactor:

+ interface ComponentConfigureResponse {
+   options?: Option[];
+   stringOptions?: string[];
+   context?: Record<string, unknown>;
+   errors?: string[];
+ }
+
- let _options = []
- if (options?.length) {
-   _options = options;
- }
- if (stringOptions?.length) {
-   const options = [];
-   for (const stringOption of stringOptions) {
-     options.push({
-       label: stringOption,
-       value: stringOption,
-     });
-   }
-   _options = options;
- }
+ const _options = [
+   ...(options ?? []),
+   ...(stringOptions?.map(str => ({ label: str, value: str })) ?? []),
+ ];

+ // Reset values set when query changes
+ useEffect(() => {
+   setPageable(prev => ({
+     ...prev,
+     values: new Set(),
+     data: [],
+     page: 0,
+     canLoadMore: true,
+   }));
+ }, [query]);

Also, verify the memory usage of the growing Set:

✅ Verification successful

The review comment's concerns and suggestions are valid

The codebase analysis confirms:

  1. The Set of values grows without cleanup as new options are loaded
  2. There's no query-dependent reset mechanism in place
  3. The suggested cleanup in a useEffect hook would prevent memory growth

The original review's refactoring suggestion should be implemented to ensure proper cleanup of the accumulated values when the query changes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for potential memory leaks in other components using similar patterns
rg -l 'new Set\(' | xargs rg 'useEffect.*\[.*query.*\]' -C 5

Length of output: 62


Script:

#!/bin/bash
# First find files using Set constructor
echo "Files using Set:"
rg "new Set\(" --type typescript

echo -e "\nEffect hooks in these files:"
rg "useEffect\(" --type typescript -A 5 -B 2

echo -e "\nQuery-dependent state updates:"
rg "setPageable|setState.*query" --type typescript -A 3 -B 3

Length of output: 442


Script:

#!/bin/bash
# Find TypeScript files and search patterns
echo "Files using Set:"
fd -e ts -e tsx | xargs rg "new Set\("

echo -e "\nEffect hooks with query dependencies:"
fd -e ts -e tsx | xargs rg "useEffect.*\[.*query.*\]" -C 5

echo -e "\nPageable state updates:"
fd -e ts -e tsx | xargs rg "setPageable\(" -C 3

Length of output: 1838


188-190: Verify ControlSelect component prop types.

Ensure that the new props are properly typed in the ControlSelect component.

✅ Verification successful

Props are properly typed in ControlSelect component

The showLoadMoreButton, onLoadMore, and options props used in RemoteOptionsContainer match the prop types defined in ControlSelect component.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check ControlSelect component prop types
ast-grep --pattern 'interface $name {
  $$$
  showLoadMoreButton?: boolean;
  onLoadMore?: () => void;
  $$$
}'

Length of output: 113


Script:

#!/bin/bash
# Find ControlSelect component definition
ast-grep --pattern 'interface ControlSelectProps {
  $$$
}'

# Also search for the component itself
ast-grep --pattern 'const ControlSelect = $$$'

# Backup search using ripgrep
rg "ControlSelect" -A 10

Length of output: 11006

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (4)
packages/connect-react/src/components/ControlSelect.tsx (4)

77-89: Move LoadMore component outside ControlSelect.

The LoadMore component should be defined outside the main component for better maintainability and reusability.

+ type LoadMoreProps = {
+   children: React.ReactNode;
+   innerProps?: Record<string, unknown>;
+ } & React.ComponentProps<typeof components.MenuList>;
+ 
+ const LoadMore = ({
+   children,
+   innerProps,
+   ...props
+ }: LoadMoreProps) => {
+   return (
+     <components.MenuList {...props}>
+       {children}
+       <div className="pt-4">
+         <LoadMoreButton onChange={onLoadMore}/>
+       </div>
+     </components.MenuList>
+   );
+ };

  export function ControlSelect<T>({
    isCreatable, options, selectProps, showLoadMoreButton, onLoadMore,
  }: ControlSelectProps<T>) {
-   const LoadMore = ({
-     children, ...props
-   }) => {
-     return (
-       <components.MenuList  {...props}>
-         { children }
-         <div className="pt-4">
-           <LoadMoreButton onChange={onLoadMore}/>
-         </div>
-       </components.MenuList>
-     )
-   }

94-95: Remove unnecessary eslint-disable comment.

After adding proper TypeScript types, this eslint-disable comment won't be needed.

- // eslint-disable-next-line react/prop-types

131-133: Use a more descriptive property name instead of __lv.

The property name __lv is cryptic. Consider using a more descriptive name that explains its purpose, such as labelValue or selectedOption.

- onChange({
-   __lv: o,
- });
+ onChange({
+   labelValue: o, // or selectedOption: o
+ });

Line range hint 138-138: Improve error handling for unhandled option types.

The current error message "unhandled option type" with a TODO comment could be more descriptive. Consider including the actual type received in the error message and handling all possible cases.

- throw new Error("unhandled option type"); // TODO
+ throw new Error(`Unhandled option type: ${typeof o}. Expected an object with 'value' property or an array.`);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f024e09 and 6fbcc4b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • packages/connect-react/src/components/ControlSelect.tsx (5 hunks)
🔇 Additional comments (1)
packages/connect-react/src/components/ControlSelect.tsx (1)

17-18: LGTM! Well-structured type definitions for pagination.

The new optional props showLoadMoreButton and onLoadMore are properly typed and maintain backward compatibility.

@bzwrk bzwrk merged commit 5f077a9 into master Jan 15, 2025
11 checks passed
@bzwrk bzwrk deleted the biz/dj-2800-add-async-options-pagination-in-connect-react branch January 15, 2025 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants