Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not export class in action server (only async function) #66641

Open
1 task done
Lucstay11 opened this issue Jun 7, 2024 · 0 comments
Open
1 task done

Can not export class in action server (only async function) #66641

Lucstay11 opened this issue Jun 7, 2024 · 0 comments
Labels
examples Issue/PR related to examples

Comments

@Lucstay11
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #35~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May  7 09:00:52 UTC 2
  Available memory (MB): 63931
  Available CPU cores: 12
Binaries:
  Node: 20.13.1
  npm: 10.5.2
  Yarn: 1.22.19
  pnpm: N/A
Relevant Packages:
  next: 14.2.3 // Latest available version is detected (14.2.3).
  eslint-config-next: N/A
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.4.5
Next.js Config:
  output: N/A

Which example does this report relate to?

...

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

I can not export class and use it with server action...

Expected Behavior

I would like juste use the classe for OOP mvc for my app!

To Reproduce

My file form/action.ts

"use server" export class User{ async changeName(form:FormData) { const name = form.get("name") console.log(name) } }

My page.tsx

`import styles from "./page.module.css";
import {User} from "./form/action"

export default function Home() {
const user = new User();
return (


  <form action={user.changeName}>
    <input type="text" name="name"></input>
    <button type="submit">Change name</button>
  </form>
  </div>
</main>

);
}`

@Lucstay11 Lucstay11 added the examples Issue/PR related to examples label Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
examples Issue/PR related to examples
Projects
None yet
Development

No branches or pull requests

1 participant