Functions are not valid as a React child?
Answered
Pacific sand lance posted this in #help-forum
Pacific sand lanceOP
i was trying to get the amount of rows in my postgresql table with prisma but i get the following error
these are my codes
Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.these are my codes
// components/admincomp/dashboard.js
"use client"
import { useEffect, useState } from "react"
import prisma from "@/lib/prisma"
export default function Dashboard() {
const getData = async (e) => {
const res = await prisma.user.count()
return res
}
return (
<div className="grid min-h-screen z-40 bg-red-950">
<div className="stats h-min w-min gap-4 m-4 shadow">
<div className="stat bg-primary">
<div className="stat-title">User amount</div>
<div className="stat-value">{getData}</div>
<div className="stat-desc">Something</div>
</div>
</div>
</div>
)
}// /app/admin/page.js
import AdminNav from "@/components/admincomponents/adminnavbar";
import Dashboard from "@/components/admincomponents/dashboard";
export default function Admin() {
return (
<>
<AdminNav/>
<Dashboard />
</>
)
}5 Replies
in div with class
stat-valuePacific sand lanceOP
oh my god
i just made the biggest mistake in my entire career
ðŸ˜