Skip to content
Discussion options

You must be logged in to vote

Found the answer, looks like it is not possible to use component props directly inside of the action so I had to pass the ID into a hidden input and after do the logic inside of the action. Here is what the final code looks like:

import config from "@/config";
import { findResource } from "../utils";
import { Resource, ResourceValue } from "@/core";
import { redirect } from "next/navigation";

export default async function New({
  params,
}: {
  params: { resourceId: string };
}) {
  const resource = findResource(config, params.resourceId);

  return (
    <main>
      <h1>New</h1>
      <Form resource={resource} />
    </main>
  );
}

const Form = ({ resource }: { resource: Resource }) => {

Replies: 3 comments 7 replies

Comment options

You must be logged in to vote
4 replies
@merveillevaneck
Comment options

@BrunoQuaresma
Comment options

@ansh
Comment options

@nikolailehbrink
Comment options

Answer selected by BrunoQuaresma
Comment options

You must be logged in to vote
3 replies
@atomicleopard
Comment options

@crissdev
Comment options

@alijawad2230
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
9 participants