Код: Выделить всё
export const addProduct = async (product: Product): Promise => {
// do something
return {
success: true
};
}
< /code>
Пример page.tsx: < /p>
import { addProduct } from '@/actions/products-actions';
const ProductsAddPage = async () => {
return
Add Post
action={addProduct}
actionType='add'
/>
;
}
export default ProductsAddPage;
< /code>
И вот определение продукта: < /p>
'use client';
interface ProductFormProps {
action: any; // this is where I have no clue what to do?
actionType: string;
}
const ProductForm = (
{
action,
actionType
}: ProductFormProps
) => {
return
{/* show something */}
;
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... pe-compone