Skip to content
Discussion options

You must be logged in to vote

Actually, I'll just toss the code in here:

import React, { useEffect, forwardRef } from 'react';

interface Props {
  indeterminate?: boolean;
  name: string;
}

const useCombinedRefs = (...refs): React.MutableRefObject<any> => {
  const targetRef = React.useRef();

  React.useEffect(() => {
    refs.forEach(ref => {
      if (!ref) return;

      if (typeof ref === 'function') {
        ref(targetRef.current);
      } else {
        ref.current = targetRef.current;
      }
    });
  }, [refs]);

  return targetRef;
};

const IndeterminateCheckbox = forwardRef<HTMLInputElement, Props>(
  ({ indeterminate, ...rest }, ref: React.Ref<HTMLInputElement>) => {
    const defaultRef = React.useRef(

Replies: 8 comments 12 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@davidjmstewart
Comment options

@victorkvarghese
Comment options

@herdeybayor
Comment options

Answer selected by RochezBaptiste
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
7 replies
@talgat-ruby
Comment options

@riceboyler
Comment options

@riceboyler
Comment options

@prasanth94
Comment options

@CatPerry
Comment options

Comment options

You must be logged in to vote
1 reply
@ggascoigne
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@victorkvarghese
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet