This code worked previously, but now that I upgraded my expo version I am getting the error
TypeError: Cannot assign to read only property 'userId' of object '#'
export interface CurrentUser {
userId: string;
...
}
This is the creation of the object
import { CurrentUser } from "../types/CurrentUser";
let currentUser: CurrentUser|null = null;
This is the assignment that is throwing the error.
export const setUserToken = async (tokenData: TokenResponse) => {
if (tokenData) {
currentUser = {
userId: "",
...
};
}
try {
await currentUserStore.setState(currentUser);
const result = await setClientsInfoByUsername();
}
export const setClientsInfoByUsername = async () => {
const data = await httpPost(...);
if (currentUser) {
currentUser.userId = data?.employee_id || ""; //Throws error
}
I'm not super familiar with React Native, so any help would be much appreciated.
I'm using expo version 54.0.21
currentUserbeing assigned. We see that you import the type. But you haven't shown the value. It's the value that is for some reason read-only. It's unclear why but it strongly implies you're not supposed to change it.