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

Relationship Graph

Source Code

packages/astro/test/fixtures/view-transitions/src/components/Island.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>
		</>
	);
}

Subdomains

Frequently Asked Questions

What does Counter() do?
Counter() is a function in the astro codebase, defined in packages/astro/test/fixtures/view-transitions/src/components/Island.jsx.
Where is Counter() defined?
Counter() is defined in packages/astro/test/fixtures/view-transitions/src/components/Island.jsx at line 4.

Analyze Your Own Codebase

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

Try Supermodel Free