next.js
8c6ac898 - Allow method properties to be server functions (#72969)

Commit
1 year ago
Allow method properties to be server functions (#72969) With this PR, we are now allowing `"use server"` and `"use cache"` to be used in method properties, e.g.: ```js export const obj = { async foo() { 'use cache' return Math.random() }, async bar() { 'use server' console.log(42) }, } ``` Or, more realistically, something like this: ```js export const api = { product: { async fetch() { 'use cache' return fetch('https://example.com').then((res) => res.json()) }, }, } ``` Supporting this pattern is mostly done for convenience; it allows users to group server functions into a common object, using method properties. Notably, we will not support the usage of `this` and `super`, for which we will add build errors in a follow-up PR.
Author
Parents
Loading