<commit_before>import ownerDocument from 'dom-helpers/ownerDocument';
import { useState, useEffect } from 'react';

const resolveRef = ref => {
  if (ref == null) return ownerDocument().body;
  if (typeof ref === 'function') ref = ref();

  if (ref && ref.current) ref = ref.current;
  if (ref && ref.nodeType) return ref;

  return null;
};

export default function useWaitForDOMRef(ref, onResolved) {
  const [resolvedRef, setRef] = useState(() => resolveRef(ref));

  if (!resolvedRef) {
    const earlyRef = resolveRef(ref);
    if (earlyRef) setRef(earlyRef);<commit_msg>fix(docs): compilation issues when building production files (#412)<commit_after>import ownerDocument from 'dom-helpers/ownerDocument';
import { useState, useEffect } from 'react';

const resolveRef = ref => {
  if (typeof document === 'undefined') return undefined;
  if (ref == null) return ownerDocument().body;
  if (typeof ref === 'function') ref = ref();

  if (ref && ref.current) ref = ref.current;
  if (ref && ref.nodeType) return ref;

  return null;
};

export default function useWaitForDOMRef(ref, onResolved) {
  const [resolvedRef, setRef] = useState(() => resolveRef(ref));

  if (!resolvedRef) {
    const earlyRef = resolveRef(ref);
    if (earlyRef) setRef(earlyRef);
{'fraction_non_alphanumeric': 0.14410134600158353, 'fraction_numerical': 0.0023752969121140144, 'mean_word_length': 4.719457013574661, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4985815', 'n_tokens_mistral': 389, 'n_tokens_neox': 380, 'n_words': 118}