Skip to content

Conversation

SEOKKAMONI
Copy link

@SEOKKAMONI SEOKKAMONI commented Oct 18, 2025

resolved #140

@SEOKKAMONI
Copy link
Author

@yudielcurbelo Please review this PR!

@yudielcurbelo yudielcurbelo requested a review from Copilot October 18, 2025 18:11
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds ref support to the Scanner component by forwarding a ref to the underlying video element and introducing a mergeRefs utility to combine internal and external refs.

  • Convert Scanner to use React.forwardRef and forward the ref to the
  • Introduce utilities/mergeRefs to merge the forwarded ref with the internal videoRef
  • Minor formatting and displayName assignment

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/utilities/mergeRefs.ts New helper to merge multiple refs; used to combine forwarded ref with internal ref.
src/components/Scanner.tsx Refactor Scanner to forwardRef, wire merged ref to the

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@@ -0,0 +1,18 @@
import { RefCallback, RefObject } from 'react';

export function mergeRefs<T>(...refs: Array<RefObject<T> | RefCallback<T> | null | undefined>): RefCallback<T> {
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

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

The signature excludes MutableRefObject and uses RefObject, which makes passing useRef refs (e.g., MutableRefObject<HTMLVideoElement | null>) a type error. Switch to React.Ref (or include MutableRefObject<T | null>) so both object and callback refs are accepted.

Copilot uses AI. Check for mistakes.

continue;
}

(ref as RefObject<T | null>).current = value;
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

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

RefObject has a readonly current; assigning to .current here is a type error. Cast to MutableRefObject<T | null> (or narrow with an appropriate type guard) before assignment: (ref as MutableRefObject<T | null>).current = value.

Copilot uses AI. Check for mistakes.

}}
className={classNames?.video} autoPlay muted playsInline />
<video
ref={mergeRefs(ref, videoRef)}
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

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

With the current mergeRefs signature (Array<RefObject | RefCallback ...>), videoRef (MutableRefObject<HTMLVideoElement | null>) is not assignable, producing a type error. This will be resolved by updating mergeRefs to accept React.Ref (or include MutableRefObject<T | null>) as suggested.

Copilot uses AI. Check for mistakes.

Repository owner deleted a comment from Copilot AI Oct 18, 2025
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.

add ref property to control zoom ,torch etc. outside of component

1 participant