-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[🐛] When migrating to the new API, what replaces database.ServerValue and storage.TaskState #8329
Comments
I believe this is fixed with the just-merged-this-morning #8322 - set to release shortly with the storage module types you need correctly importable at top level from the our modular implementation exports |
Great, thanks! We need similar thing for the database right? |
Database is a bit different, we didn't port over the statics because there is another way of getting the timestamp. Call this function: https://github.com/invertase/react-native-firebase/blob/main/packages/database/lib/modular/index.js#L111 which is the firebase-js-sdk way of retrieving it. e.g. import database, { serverTimestamp } from '@react-native-firebase/database';
// namespaced - deprecated way
const timestamp = database.ServerValue.TIMESTAMP;
// modular - latest way
const timestamp = serverTimestamp(); |
Thank you. I dont need the TimeStamp..I need ServerValue.increment() |
You need to use this function then: https://github.com/invertase/react-native-firebase/blob/main/packages/database/lib/modular/index.js#L120 import database, { increment } from '@react-native-firebase/database';
// namespaced - deprecated way
const incrementUpdate = database.ServerValue.increment(1);
// modular - latest way
const incementUpdate = increment(1); |
In the new version, there seems to be a new problem. export function serverTimestamp() {
return firebase.database.ServerValue.TIMESTAMP;
}
/**
* @param {number} delta
* @returns {object}
*/
export function increment(delta) {
return firebase.database.ServerValue.increment(delta);
} "firebase" is not defined in packages/database/lib/modular/index.js |
@nes123 what happens if you patch those (that is: editing file directly in node_modules as a test) to read: export function serverTimestamp() {
return getApp().database.ServerValue.TIMESTAMP;
}
/**
* @param {number} delta
* @returns {object}
*/
export function increment(delta) {
return getApp().database.ServerValue.increment(delta);
}
I haven't tried this, might not work at all, but I think it may fix it |
It does not work..will it be a mistake to revert and import firebase as before: import { firebase } from '..'; |
I get these warnings:
This v8 method is deprecated and will be removed in the next major release as part of move to match Firebase Web modular v9 SDK API. Please use
getApp()
instead.I migrated most of the methods but didnt find a replacement to database.ServerValue and storage.TaskState
The text was updated successfully, but these errors were encountered: