// WRONG — a function prop passed from Astro's frontmatter
// does not survive the serialization boundary:
//
// ---
// function handleClick() { alert('clicked'); }
// ---
//
//
// This fails because handleClick is a function, not serializable
// data, and Astro's frontmatter isn't running in the browser anyway
// — there's no live function reference to hand across the boundary.
// CORRECT — src/components/ReactButton.jsx
import { useState } from 'react';
export default function ReactButton() {
const [clicked, setClicked] = useState(false);
function handleClick() {
setClicked(true);
}
return (
);
}
---
// src/pages/index.astro
import ReactButton from '../components/ReactButton.jsx';
---