@yamlresume/playground
    Preparing search index...

    Function useResumeState

    • A React hook for managing resume state derived from YAML content.

      Parameters

      Returns {
          activeLayoutIndex: number;
          handleYamlChange: (v: string) => void;
          resume: Resume;
          setActiveLayoutIndex: Dispatch<SetStateAction<number>>;
          yaml: string;
      }

      An object containing:

      • yaml - The current YAML string content
      • handleYamlChange - Function to notify parent of YAML changes
      • activeLayoutIndex - The currently selected layout index
      • setActiveLayoutIndex - Function to change the active layout
      • resume - The parsed Resume object (or null if parsing fails)

      This hook encapsulates the logic for:

      • Parsing YAML into a Resume object with memoization
      • Tracking the active layout index with bounds checking
      • Providing a change handler that notifies the parent

      The parent component is responsible for managing the YAML state. This hook simply derives state (parsed resume, layout index) from the provided YAML and exposes utilities for updates.

      // Parent manages state, hook derives resume object
      const [yaml, setYaml] = useState(defaultYaml)
      const { resume, activeLayoutIndex } = useResumeState({
      yaml,
      onChange: setYaml,
      })