I am able to get the data in categoryMap from firebase firestore but I want to save the data in a state and then share that state between components using redux toolkit. Should I create action creators in the code below or should I use react's useState hook and then apply redux on top of that?
Here is the code snippet of the data I get from firestore:
export const getCategoriesAndDocuments = async () => {
const collectionRef = collection(db, 'categories');
const q = query(collectionRef);
const querySnapshot = await getDocs(q);
const categoryMap = querySnapshot.docs.reduce((acc, docSnapshot) => {
const { title, items } = docSnapshot.data();
acc[title.toLowerCase()] = items;
return acc;
}, {});
};