Home / Function/ Counter() — astro Function Reference

Counter() — astro Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  59bde57b_df80_753b_2979_4ac60a4ee8be["Counter()"]
  0b864290_5305_c122_d20e_7d3d701ccd6f["Counter.tsx"]
  59bde57b_df80_753b_2979_4ac60a4ee8be -->|defined in| 0b864290_5305_c122_d20e_7d3d701ccd6f
  style 59bde57b_df80_753b_2979_4ac60a4ee8be fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

examples/framework-react/src/components/Counter.tsx lines 4–25

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

	return (
		<>
			<div className="counter">
				<button onClick={subtract}>-</button>
				<pre>{count}</pre>
				<button 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 examples/framework-react/src/components/Counter.tsx.
Where is Counter() defined?
Counter() is defined in examples/framework-react/src/components/Counter.tsx at line 4.

Analyze Your Own Codebase

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

Try Supermodel Free