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

Relationship Graph

Source Code

packages/astro/e2e/fixtures/react-component/src/components/Counter.jsx lines 4–19

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>
			<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/react-component/src/components/Counter.jsx.
Where is Counter() defined?
Counter() is defined in packages/astro/e2e/fixtures/react-component/src/components/Counter.jsx at line 4.

Analyze Your Own Codebase

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

Try Supermodel Free