DevFlow

DevOverflow

Search
Menu
DevFlow

DevOverflow

Home menu icon

Home

Community menu icon

Community

Collections menu icon

Collections

Find Jobs menu icon

Find Jobs

Tags menu icon

Tags

Ask a question menu icon

Ask a question

    Menu

    Top Questions

    How to center a div?

    chevron

    How to do code parsing with React.js and NextJS?

    chevron

    How to get better at Nextjs?

    chevron

    Postgres: upgrade a user to be a superuser? ?

    chevron

    This is another test question

    chevron

    Popular Tags

    nextjs

    6

    React

    4

    next.js

    3

    reactjs

    3

    css

    3

    Profile

    Juan Cruz Cáceres

    upvote

    0

    downvote

    0

    star

    Error: Functions cannot be passed directly to Client Components

    clock icon

    Asked 9 months ago

    message

    0 Answers

    eye

    1 Views

    0

    I am using nextjs 14 app router. But i am getting the error: "Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server". Or maybe you meant to call this function rather than return it."

    My question is why the error message mentioning Client Component when there is no client component in my code.

    //index.js
    export const handleSubmit = async(formData) => {
        console.log(formData.get("name"));
    }
    
    //AddTaskForm.jsx
    import {handleSubmit} from "@/app/action/index"
    const AddTaskForm = () => {
        return (
            <form action={handleSubmit} className="mt-10 flex flex-col gap-4 w-[300px] mx-auto">
                <div className="flex flex-col gap-2">
                    <label htmlFor="name">Name</label>
                    <input className="border border-black" type="text" id="name" name="name" />
                </div>
                <button type="submit" className="bg-purple-500 py-2">Submit</button>
            </form>
        );
    };
    export default AddTaskForm;
    
    //page.js
    import AddTaskForm from '@/app/ui/AddTaskForm';
    export default function Home() {
      return (
        <AddTaskForm/>
      );
    }
    

    Is the error message misleading?

    nextjs
    next14
    app-router

    Write your answer here

    0 Answers