import { useEffect } from 'react';
import { useSessionQueryName } from '../stores/editor-store';

/**
 * This component isolates the work of updating the document title on query name changes.
 * This is a component to prevent the main QueryEditor component from rendering on name change.
 * @param {object} props
 */
function DocumentTitle({ queryId }: { queryId: string }) {
  const queryName = useSessionQueryName();
  const title = queryId === '' ? 'New query' : queryName;

  useEffect(() => {
    document.title = title;
  }, [title]);

  return null;
}

export default DocumentTitle;

import { useSessionQueryName } from '../stores/editor-store';

/**
 * This component isolates the work of updating the document title on query name changes.
 * This is a component to prevent the main QueryEditor component from rendering on name change.
 * @param {object} props
 */
function DocumentTitle({ queryId }: { queryId: string }) {
  const queryName = useSessionQueryName();
  const title = queryId === '' ? 'New query' : queryName;

  if (document.title !== title) {
    console.log('updating title');
    document.title = title;
  }

  return null;
}

export default DocumentTitle;

Fix document title not changing on sign in
Fix document title not changing on sign in
