Home / Function/ Counter() — astro Function Reference

Counter() — astro Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  90c6fe99_b6ed_ac6e_aaae_ffb8ab584758["Counter()"]
  fabef3ac_fe75_f59e_da03_824e9a40f3fd["Island.jsx"]
  90c6fe99_b6ed_ac6e_aaae_ffb8ab584758 -->|defined in| fabef3ac_fe75_f59e_da03_824e9a40f3fd
  style 90c6fe99_b6ed_ac6e_aaae_ffb8ab584758 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/e2e/fixtures/view-transitions/src/components/Island.jsx lines 5–21

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

	return (
		<>
			<div id={id} className="counter">
				<h1 className="page">{page}</h1>
				<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/view-transitions/src/components/Island.jsx.
Where is Counter() defined?
Counter() is defined in packages/astro/e2e/fixtures/view-transitions/src/components/Island.jsx at line 5.

Analyze Your Own Codebase

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

Try Supermodel Free