Skip to content

Conversation

danybeltran
Copy link
Member

@danybeltran danybeltran commented Apr 20, 2024

  • Enhances the useServerAction hooks by making id optional and creating mock ids internally
  • Provides better code documentation

Usage:

// actions.ts
'use server'

export async function getData({ id }: { id :string }) {
  const dt = await getDbData()

  return { data: dt }
}
// page.tsx
'use client'
import { useServerAction } from "http-react"

import { getData } from "@/actions"

export default function Page() {
  // type of 'data' is inferred
  const { data, loading } = useServerAction(getData, {
    params: {
      id: "some-id",
    },
  })

  return ...
}

- Enhances the useServerAction hooks by making id optional and creating mock ids internally
- Provides better code documentation
@danybeltran danybeltran merged commit 15eb418 into master Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant