import * as React from 'react';
import { useComponentRenderer } from '../utils/useComponentRenderer.js';
const emptyObject = {};

/**
 * Returns an object with a `renderElement` function that renders a Base UI element.
 */
export function useRender(params) {
  const {
    render,
    props,
    state,
    refs
  } = params;
  const {
    ref,
    ...extraProps
  } = props ?? {};
  const refsArray = React.useMemo(() => {
    return [...(refs ?? []), ref].filter(Boolean);
  }, [refs, ref]);
  return useComponentRenderer({
    render,
    state: state ?? emptyObject,
    ref: refsArray,
    extraProps,
    styleHooks: false
  });
}