In firestore, I have this fields title
, createdDate
, and text
. How do I display the fields title
and createdDate
in the mui-datatable. The text
would then be displayed inside the expanded row. How can I do this?
This is what the data looks like if I'll console.log the blogs
:
const columns = ["Title", "Created Date"];
const [blogs, setBlogs] = useState([]);
useEffect(() => {
const unsubscribe = firestore
.collection("blogs")
.onSnapshot((snapshot) => {
const arr = [];
snapshot.forEach((doc) => {
const data = doc.data();
arr.push({
text: parse(data.text),
Title: data.title,
"Created Date": new Date(
data.createdDate.seconds * 1000
).toDateString(),
});
});
setBlogs(arr);
setIsLoading(true);
});
return () => {
unsubscribe();
};
}, []);
const options = {
filter: true,
expandableRows: true,
renderExpandableRow: (rowData, rowMeta) => {
console.log(); //how do I render the `text` here from firestore?
},
};
Inside the return: I tried putting the blogs
inside the data but it doesn't work. No data is showing.
<MUIDataTable
title={"List"}
columns={columns}
data={blogs}
options={options}
/>