Closed shidevil closed 1 year ago
Tested in the sample - https://benwinding.github.io/react-admin-firebase/
Did not work as well
I had different error but the same problem. If you are using the lib without authentication fireWrapper.authGetUserLoggedIn() returns a rejection which is uncaught and breaks the flow. @benwinding might be worth looking into this.
@Georgi-Slavchev did you managed to solve ur issue?
Yes sorry, I was not very clear on that. Inside the ResourceManager.ts there are two functions: getCurrentUserEmail, getCurrentUserId. I replaced the if - else with try catch where in the catch I just return the logic from the else.
could you share the code @Georgi-Slavchev and probably can do a pull request if it’s broken.
I had the same issue and resolved it by simply filtering out the undefined fields.
When you initialize the dataprovider you can pass the transformToDb
option to it.
import {FirebaseDataProvider} from "react-admin-firebase";
const config = {
apiKey: "aaaaaaaaaaaaaaaaaaaaaaaaaaa",
authDomain: "aaaaaaaaaaaaaaaaaaaaaaaaaaa",
databaseURL: "aaaaaaaaaaaaaaaaaaaaaaaaaaa",
projectId: "aaaaaaaaaaaaaaaaaaaaaaaaaaa",
storageBucket: "aaaaaaaaaaaaaaaaaaaaaaaaaaa",
messagingSenderId: "aaaaaaaaaaaaaaaaaaaaaaaaaaa",
};
const dataProvider = FirebaseDataProvider(config, {
app: firebaseAppInstance,
transformToDb: (resourceName, documentData) => {
// remove undefined fields from the document, since firestore does not accept undefined as a field value
return Object.fromEntries(
Object.entries(documentData).filter(([, val]) => val !== undefined)
);
}
});
It's not a catch all clause because it would not remove undefineds for nested objects, but for your purpose it seems satisfactory.
It is a solution assuming you do not want the fields to be added, but if you still want the fields in the result, instead of filtering out the field, you could map them to nulls or better yet set default values for form inputs to nulls.
It's a little problematic implementing it recursively because certain class objects like for instance firebase Timestamp from datefield, would turn into an object instead of remaining a class.
I just ran into the same issue as well, I think this is still a breaking issue if you are not using authentication. @benwinding and the rest, do you know whether someone is on this? If not, I could take a look (but cannot promise to deliver a solution as I am short on time right now). Would you mind reopening the issue, or should I create a new one?
Hi everyone,
I just want to check so there seems to be an issue with the create post, and it can't be created. I have not touched any code yet.
I would appreciate any help!