You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Previously it was working with version 2.0 but after I upgrade to version 3.0, it crashed
export const firestoreState = atom({
key: "firestore", // unique ID (with respect to other atoms/selectors)
default: firebase.app().firestore(), // default value (aka initial value)
});
export const allMovieState = selector({
key: "allMovieState",
get: async ({ get }) => {
// Get your firestore instance
const firestore = get(firestoreState);
// Use it!
const movies = await firestore.collection("movies").get();
const movieNames = [...movies.docs].map((doc) => {
const movieData = doc.data();
return {
id: doc.id,
title: movieData.title,
assetRef: movieData.assetRef, // refers to the streaming asset
};
});
return movieNames;
},
});
It said something relating to _frozenObject.
The text was updated successfully, but these errors were encountered:
There were some fixes where Recoil will now properly freeze objects stored as values in selectors in dev mode. This is done to help catch issues where users may attempt to mutate objects thinking they are changing state whereas all state changes must go through a proper Recoil set.
First question is if you or firebase is expecting to mutate these objects and if that could be avoided? If not, does the mutation represent a state change? If it doesn't then you can workaround the object freezing by maybe storing a handle to the object instead of the object itself or using the dangerouslyAllowMutability option for the selector.
drarmstr
changed the title
Recoil 3.0 cannot work with firebase
[firebase] Recoil 3.0 cannot work with firebase
Jun 2, 2021
Hi,
I tried it but it still cried out cloud. Here is my setup for firebase:
export const firestoreState = selector({
key: "firestoreState",
get: () => {
return firebase.app().firestore()
},
dangerouslyAllowMutability: true,
})
And i got this error: TypeError: Cannot assign to read only property '_settingsFrozen' of object '#'
Version 2.0 is working for this way, is there anyway to workaround?
Previously it was working with version 2.0 but after I upgrade to version 3.0, it crashed
export const firestoreState = atom({
key: "firestore", // unique ID (with respect to other atoms/selectors)
default: firebase.app().firestore(), // default value (aka initial value)
});
export const allMovieState = selector({
key: "allMovieState",
get: async ({ get }) => {
// Get your firestore instance
const firestore = get(firestoreState);
// Use it!
const movies = await firestore.collection("movies").get();
const movieNames = [...movies.docs].map((doc) => {
const movieData = doc.data();
return {
id: doc.id,
title: movieData.title,
assetRef: movieData.assetRef, // refers to the streaming asset
};
});
return movieNames;
},
});
It said something relating to _frozenObject.
The text was updated successfully, but these errors were encountered: