I want to map an array from react's useState hook, but I get the error:
TypeError: documents.map is not a function
This is my code:
const [docs, setDocs] = useState(documents);
const rows = documents.map((doc) => (
<tr key={doc.id}>
<td>
<Group spacing="sm">
...
where "documents" comes from props.
I console-logged docs and it prints out an array. What am I missing here? Is it, because "docs" is a state value?
To further clarify: I fetch the documents from supabase and want to integrate a realtime subscription.
Whenever I get a change in the db, the useEffect function triggers the setState function. Then the error appears. So I am not sure how to handle this with default values.