// Copyright (c) Meta Platforms, Inc. and affiliates. 'use client'; import {useRef, useState} from 'react'; import {Button} from '@astryxdesign/core/Button'; import {Heading, Text} from '@astryxdesign/core/Text'; import {HStack, VStack} from '@astryxdesign/core/Layout'; import {Outline, useOutlineFromDOM} from '@astryxdesign/core/Outline'; import {ScrollableArea} from '@astryxdesign/core/ScrollableArea'; const SECTIONS = [ {id: 'before-you-start', title: 'Before you start'}, {id: 'run-the-upgrade', title: 'Run the upgrade'}, {id: 'check-the-result', title: 'Check the result'}, ]; export default function UseOutlineFromDOMHookUsage() { const articleRef = useRef(null); const items = useOutlineFromDOM(articleRef); const [extra, setExtra] = useState(0); return ( {SECTIONS.map(section => ( {section.title} The outline reads this heading from the article. ))} {Array.from({length: extra}, (_, index) => ( New section The button added this heading. ))}