Kent C. Dodds
09/24/2021, 3:13 PMconst users = await prismaRead.user.findMany({
select: {
firstName: true,
email: true,
id: true,
team: true,
},
orderBy: {
createdAt: 'asc',
},
})
const data: LoaderData = {users}
return data // this gets sent over the network as json
// then later, on the other side of a network request, in a React component for example:
const data = useLoaderData()
assert(data, LoaderData)
data.users[0].firstName // <-- autocompletes
Kent C. Dodds
09/24/2021, 3:15 PMKent C. Dodds
09/24/2021, 3:16 PMKent C. Dodds
09/24/2021, 3:16 PMAhmed
09/24/2021, 3:17 PMKent C. Dodds
09/24/2021, 3:19 PMKent C. Dodds
09/24/2021, 3:19 PMRyan
09/27/2021, 7:00 AM