GetCurrentUser Deprecated in React: Replacement
GetCurrentUser is not a React API, so React itself has not deprecated it; the warning comes from the authentication, consent, admin, or backend package that owns the method. The safe fix is to identify that package from the import or warning text, then use that package’s current API without changing the meaning of “current user.” For Parse in React Native, current-user retrieval is asynchronous; for Didomi, several older status methods were replaced by a current-status API.
Match the exact warning or method call before changing code.
| What You See | Likely Meaning | Safe Fix |
|---|---|---|
Parse.User.currentAsync() in a React Native app |
The locally stored Parse user must be loaded asynchronously | Await the call, then handle a possible null result |
Didomi calls such as getDisabledPurposes() |
A removed or deprecated consent-status method is still in use | Use getCurrentUserStatus and read the appropriate status field |
A warning mentioning SaveContextProvider |
A react-admin Create or Edit component is relying on deprecated props | Put the component under the required context provider and use context-based data |
A generic getCurrentUser() warning |
A third-party package changed its API | Find the method’s package import and follow that package’s migration path |
Why React Is Not the Owner of GetCurrentUser
React renders UI from state and props. It does not define a built-in getCurrentUser(), GetCurrentUser(), or global authentication store.
A current-user method normally belongs to one of these layers:
- An authentication SDK that stores a signed-in identity.
- A backend SDK that restores a session from device or browser storage.
- A consent-management SDK that exposes a consent profile and status.
- An admin framework that supplies data through React context.
- Your application’s own auth provider or custom hook.
JavaScript is case-sensitive, so GetCurrentUser, getCurrentUser, getCurrentUserStatus, and Parse.User.currentAsync are unrelated APIs unless their package documentation explicitly connects them.
A current-user lookup is only meaningful when you know which package created and stored that user state.
Before replacing anything, inspect the import at the top of the file and the complete console warning. The package name, not the word “React”, determines the correct migration.
How to Fix a Deprecated GetCurrentUser Call
A safe replacement matches the method owner and return shape while handling loading, signed-out, sign-in, sign-out, and account-switching states.
Step 1: Identify the Method Owner
- Find the deprecated method in your codebase.
- Check its import, namespace, or object prefix. For example,
Parse.User.currentAsyncbelongs to Parse, whileDidomi.getCurrentUserStatusbelongs to Didomi. - Copy the complete warning text, including the old method name, suggested replacement, and installed package version.
- Check your package lock file or dependency manifest so you use documentation that matches the major version installed in the project.
Do not replace a method based only on a similar name from another library. A “current user” in a consent SDK is not the same object as an authenticated Parse user.
Step 2: Preserve the Old Method’s Job
- Determine what the old code needed: an authenticated account, a username, a session token, consent choices, or admin persistence callbacks.
- Check whether the replacement is synchronous or asynchronous.
- Confirm the replacement’s documented return shape before updating property reads.
- Update the code that reads properties from the returned value.
For example, replacing a synchronous call with an asynchronous one requires await and loading-aware UI state. Replacing a method that returned an array with one that returns a full status object requires reading the correct nested field.
Step 3: Keep Signed-Out and Loading States Safe
- Check for
nullor the package’s documented empty result before reading a username, ID, or consent field. - Keep authorization checks separate from display logic. Showing a locally stored username does not, by itself, authorize a protected server request.
Avoid this unsafe pattern:
const user = await getCurrentUser();
return user.username;
That direct property access assumes a session is already available.
Step 4: Remove the Deprecated Path and Test the Full Flow
- Remove calls to the deprecated method after the replacement is working.
- Test with a signed-in user.
- Test sign-in, sign-out, and account-switching flows so the UI updates instead of retaining stale identity data.
- In development, keep the lookup safe to run more than once because React development behavior can re-run effects to expose side-effect problems.
A complete migration ends when the warning is gone and user-state transitions render correctly.
Get the Current User in Parse React Native
In a Back4App React Native app, Parse restores the locally stored user through AsyncStorage, so the lookup must be asynchronous. Back4App’s React Native Parse guidance uses this React Native import:
import Parse from 'parse/react-native';
Retrieve the user with:
const currentUser = await Parse.User.currentAsync();
The result is either a Parse.User object or null. Check for null before accessing a property:
if (currentUser !== null) {
const username = currentUser.getUsername();
}
Use the Lookup Inside a Component
Do not make the useEffect callback itself async. React expects an effect to return nothing or a cleanup function, while an async function returns a Promise. Instead, define an inner async function and call it from the effect.
import React, { useEffect, useState } from 'react';
import { Text } from 'react-native';
import Parse from 'parse/react-native';
export function HelloUser() {
const [username, setUsername] = useState('');
useEffect(() => {
let canceled = false;
async function getCurrentUser() {
const currentUser = await Parse.User.currentAsync();
if (!canceled && currentUser !== null) {
setUsername(currentUser.getUsername());
}
}
getCurrentUser();
return () => {
canceled = true;
};
}, []);
return username ? <Text>Hello {username}</Text> : null;
}
The cleanup flag prevents the component from updating state after it has unmounted. If your app needs to distinguish “loading,” “signed out,” and “storage failed,” add separate state for those conditions rather than treating every result as a username.
Use currentAsync() for locally restored user data. If an action requires a valid server session, let the server or Parse request itself enforce that requirement.
Migrate Didomi Current-User Status Calls
Didomi’s React Native SDK has deprecated and removed several separate user-status methods in favor of a current-status API. The Didomi deprecated API documentation marks getDisabledPurposes and getDisabledPurposeIds as removed since version 2.0.0 and directs apps to getCurrentUserStatus.
The important change is that the replacement exposes a broader status object. Read the needed category from that status rather than expecting each old method to return its own list.
| Older Didomi Call | Current Status Migration | Status Field for the Former Result |
|---|---|---|
getDisabledPurposes() or getDisabledPurposeIds() |
Use getCurrentUserStatus |
getUserStatus().purposes.consent.disabled |
getEnabledPurposes() or getEnabledPurposeIds() |
Use getCurrentUserStatus |
getUserStatus().purposes.global.enabled |
getDisabledVendors() or getDisabledVendorIds() |
Use getCurrentUserStatus |
getUserStatus().vendors.consent.disabled |
getEnabledVendors() or getEnabledVendorIds() |
Use getCurrentUserStatus |
getUserStatus().vendors.consent.enabled |
The documented paths describe where each older result lives in the status data. Use the current-status method to obtain the status object, then read the matching nested category.
Be precise about the consent category:
- Disabled purposes use the
purposes.consent.disabledbranch. - Enabled purposes use the
purposes.global.enabledbranch. - Disabled vendors use the
vendors.consent.disabledbranch. - Enabled vendors use the
vendors.consent.enabledbranch.
Do not assume that “enabled” and “disabled” always use parallel global or consent paths. Use the documented field that corresponds to the specific old method you are replacing.
If the Warning Mentions SaveContextProvider
A warning that says Create or Edit child components must be used inside SaveContextProvider is a react-admin persistence-context warning, not a React current-user warning.
It appears when custom Create or Edit components receive save-related data through props instead of the context that newer react-admin versions expect. The repair is to ensure the custom component is rendered within the required provider/controller structure and reads persistence-related data from context.
Do not try to solve this warning by adding an authentication getCurrentUser() call. The warning concerns save callbacks and edit/create state, not the signed-in account.
Confirm the Migration Works
Use this checklist after updating the code:
- The browser or device console no longer shows the deprecation warning.
- A signed-in user’s UI can read the needed display property.
- Signing out clears or replaces user-specific UI.
- Signing in or switching accounts refreshes the displayed state.
- Consent code reads the intended purpose or vendor branch from the returned status object.
Keep current-user access behind a small adapter, hook, or provider in your application. That gives the rest of the UI one stable interface and limits future SDK migrations to one place.
Frequently Asked Questions
Is GetCurrentUser Deprecated in React?
No. React does not provide a built-in GetCurrentUser or getCurrentUser API. A deprecation warning comes from the package that owns the method, such as an auth SDK, backend SDK, consent SDK, or admin framework.
How Do I Get the Current Logged-In User in React Native With Parse?
Use await Parse.User.currentAsync() after importing Parse with import Parse from 'parse/react-native';. The result can be null, so check currentUser !== null before calling currentUser.getUsername() or another user accessor.
Why Can’t I Make useEffect Async?
An effect callback should return either nothing or a cleanup function, while an async function returns a Promise. Define an inner async function inside useEffect, call it after declaration, and return a normal cleanup function if the component may unmount before the lookup finishes.
What Replaces Didomi getDisabledPurposes?
Since Didomi SDK version 2.0.0, use getCurrentUserStatus instead of getDisabledPurposes or getDisabledPurposeIds. The disabled-purpose result is represented by getUserStatus().purposes.consent.disabled in Didomi’s documented status mapping.
Why Does My Warning Mention SaveContextProvider Instead of a User?
The SaveContextProvider warning identifies react-admin’s save context rather than authentication. Custom Create and Edit components need the save-related context supplied by the appropriate provider/controller structure rather than relying on deprecated props.
