Home / Function/ Counter() — astro Function Reference

Counter() — astro Function Reference

Architecture documentation for the Counter() function in Counter.jsx from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  f31d0a59_2f33_310a_860d_f88ede910e07["Counter()"]
  1cff5a89_304f_5d58_30e4_07a283fac963["Counter.jsx"]
  f31d0a59_2f33_310a_860d_f88ede910e07 -->|defined in| 1cff5a89_304f_5d58_30e4_07a283fac963
  style f31d0a59_2f33_310a_860d_f88ede910e07 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/e2e/fixtures/preact-lazy-component/src/components/Counter.jsx lines 8–25

export default function Counter({ children, count: initialCount, id }) {
	const [count, setCount] = useState(initialCount);
	const add = () => setCount((i) => i + 1);
	const subtract = () => setCount((i) => i - 1);

	return (
		<>
			<div id={id} className="counter">
				<button className="decrement" onClick={subtract}>-</button>
				<pre>{count}</pre>
				<button className="increment" onClick={add}>+</button>
			</div>
			<Suspense fallback={<p>Load message...</p>}>
				<LazyCounterMessage className="counter-message">{children}</LazyCounterMessage>
			</Suspense>
		</>
	);
}

Domain

Subdomains

Frequently Asked Questions

What does Counter() do?
Counter() is a function in the astro codebase, defined in packages/astro/e2e/fixtures/preact-lazy-component/src/components/Counter.jsx.
Where is Counter() defined?
Counter() is defined in packages/astro/e2e/fixtures/preact-lazy-component/src/components/Counter.jsx at line 8.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free