#Client Functions cannot be passed directly to Server Functions

9 messages · Page 1 of 1 (latest)

pale flower
#

I'm having an issue calling one of my actions in a client component. What I have is a form with an attribute of action, this calls a function which saves one of the form data and calls a server function. However, it doesn't allow me to make the request.. why?
Uncaught Error: Client Functions cannot be passed directly to Server Functions. Only Functions passed from the Server can be passed back again.

/page.tsx

<form action={(data) => handleSubmit(data, user, isNewGoogleUser)} className={styles.form__container} autoComplete="true">
                <div className={styles.form__option}>
                    <label htmlFor="highschool">High School</label>
                    <div className={`${styles.input__container} ${styles.input__option}`}>
                        <Image src={"/svgs/info-circle.svg"} alt="Info Icon" width={20} height={20} />
                        <input type="text" id="highschool" name="highschool" onChange={({ target }) => user.setProperty("currentHighschool", target.value)} placeholder="Tell us your current highschool" />
                    </div>
                </div>

                <button type="submit" className={styles.next}>
                    <Image src={"/svgs/thumb-up.svg"} alt="Thumbs Up" width={24} height={24} />
                    Finish
                </button>
            </form>
// * Handle storing and submitting data
async function handleSubmit(data: FormData, user: UserInfo, isNewGoogleUser: boolean) {
    const highschool = data.get("highschool");
    if (highschool) user.setProperty("currentHighschool", highschool);

    createUser(user, isNewGoogleUser)
}

_actions/info.ts

export async function createUser(user: UserInfo, isGoogleUser: boolean) {
  console.log(user, isGoogleUser);

  return;
}
still grottoBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

pale flower
#

List of all errors:

#

Only happens when I call createUser

#

Gonna send my whole code, won't be on much longer and really need help!

pale flower
#

Noticed that if I made user and isGoogleUser a string, it works