We've all fought the "Cannot read property 'x' of undefined" battle. Instead of writing long chains of if (user && user.profile && user.profile.name), use the optional chaining operator (?.). Writing user?.profile?.name will safely return undefined if any part of the chain is missing, preventing your app from crashing. It makes your code much cleaner and more resilient.
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)