'use client' import React, { Fragment } from 'react' import { useDocumentInfo } from '../../providers/DocumentInfo/index.js' import { IDLabel } from '../IDLabel/index.js' import './index.scss' const baseClass = 'render-title' export type RenderTitleProps = { className?: string element?: React.ElementType fallback?: string fallbackToID?: boolean title?: string } export const RenderTitle: React.FC = (props) => { const { className, element = 'h1', fallback, title: titleFromProps } = props const { id, isInitializing, title: titleFromContext } = useDocumentInfo() const title = titleFromProps || titleFromContext || fallback const idAsTitle = title === id const Tag = element // Render and invisible character to prevent layout shift when the title populates from context const EmptySpace =   return ( {isInitializing ? ( EmptySpace ) : ( {idAsTitle ? : title || EmptySpace} )} ) }