export function mergeRefs(refs) {
	return (value) => {
		refs.forEach((ref) => {
			if (typeof ref === "function") {
				ref(value);
			} else if (ref != null) {
				ref.current = value;
			}
		});
	};
}

/////////////////////
/////// Usage ///////
/////////////////////

const SomeComponent = forwardRef((props, ref) => {
  const someOtherRef = React.useRef();
  
  return <div ref={mergeRefs([someOtherRef, ref])} />;
});
  
// Note:
// This repo does basically the same thing, but it's TypeScript-y,
// so it might be "safer" or whatever
// https://github.com/gregberge/react-merge-refs