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
  5d2f2bd1_b283_1f96_a357_1893e2634c18["Counter()"]
  664f475e_1b97_7377_9afb_71646d925161["Counter.jsx"]
  5d2f2bd1_b283_1f96_a357_1893e2634c18 -->|defined in| 664f475e_1b97_7377_9afb_71646d925161
  style 5d2f2bd1_b283_1f96_a357_1893e2634c18 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/e2e/fixtures/custom-client-directives/src/components/Counter.jsx lines 3–18

export default function Counter({ children, count: initialCount = 0, 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>
			<div className="counter-message">{children}</div>
		</>
	);
}

Domain

Subdomains

Frequently Asked Questions

What does Counter() do?
Counter() is a function in the astro codebase, defined in packages/astro/e2e/fixtures/custom-client-directives/src/components/Counter.jsx.
Where is Counter() defined?
Counter() is defined in packages/astro/e2e/fixtures/custom-client-directives/src/components/Counter.jsx at line 3.

Analyze Your Own Codebase

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

Try Supermodel Free