I need a lot of help. I'm working on a library that allows you to format data like this:
export default function Page() {
return (
<Collection
path="/posts"
where={["content", "==", "test"]}
render={(data) => (
<div className="bg-zinc-100 rounded-lg p-4">
<pre className="font-medium">
{JSON.stringify(data, null, 2)}
</pre>
</div>
)}
/>
);
}
export const Collection: React.FC<CollectionProps> = ({
path,
where,
render,
loadingSlot,
}) => {
const { db } = useGlobalFirebase();
if (db === null) {
console.error("Firebase db context not found");
return null;
}
const [data, loading] = useCollection<DocumentData[]>(db, path, where);
if (loading) {
return <>{loadingSlot || <div>Loading...</div>}</>;
}
if (!data) {
return <div>No data found</div>;
}
return <>{render(data)}</>;
};
This works just fine in React, but when I go to Next with it, it breaks.
<... path="/posts" where={[...]} render={function render}>
^^^^^^^^^^^^^^^^^```
I've tried everything and I don't know if this is even possible to have it work like this. Please help, lmfao