react element as an arg?
Hi team! is it wrong to pass react element as an argument? im getting
for doing
6 Replies
Yes it is: arguments to Convex functions need to be serialized into Convex values https://docs.convex.dev/database/types.
It's too bad this is a bad error message, but even if the serialization protocol did allow fields to start with
$$
(which it could in the future) a React element is not round-trip serializeable, it's not pure JSONgot it! do you think there's a work around i can do?
So I'd use an enum-like string to identify the template and then do the templating on the other side of the call
so sendEmail() would check arg.emailTemplate and choose the appropriate template based on the string. And any data needed.
ack. that's what i was thinking. thanks!
is there a way to do v.enum? i dont see it in the types link https://docs.convex.dev/database/types
Data Types | Convex Developer Hub
All Convex documents are defined as Javascript objects. These objects can have
you probably want v.union https://docs.convex.dev/database/schemas#unions
Schemas | Convex Developer Hub
Schema validation keeps your Convex data neat and tidy. It also gives you end-to-end TypeScript type safety!