#Prop function not "defined" in a client component on a pre-rendered page

4 messages · Page 1 of 1 (latest)

inner shard
#

I'm passing an arrow function to a React Combobox component inside a dynamic pre-rendered page but getting a onSelect is not a function error. Any thoughts?

---
// other js code

export const prerender = true;
---

<BaseLayout title={tag ?? "tag"}>
  <div class="flex gap-2 items-center">
    <p>Posts tagged with</p>
    <Combobox
      initialValue={tag ?? ""}
      options={tags}
      onSelect={(option) => {
        // this function throw and error when it is run on click
        Astro.redirect(`/tags/${option}`);
      }}
      client:load
    />
  </div>
  // ...
</BaseLayout>
zealous bridgeBOT
#
Quiet in here?

It looks like no-one has responded to your question yet. People might not be available right now or don’t know how to answer your question. Want an answer while you wait? Try asking our experimental bot in #1095492539085230272.

tired dune
#

You can't pass function from astro to ui frameworks as prop because they are serializable

#

Astro.redirect is only meant to be used in the frontmatter btw, you can just use window.location.assign client side