Visual Studio Code syntax highlighting is not working for JavaScript and TypeScript

I think this was caused by the extension called JavaScript and TypeScript Nightly. This was causing the syntax highlighting for .js and .ts files (.jsx and .tsx too). This was more of a bug with the latest version (currently 1.73.1). You can disable the extension to enable the syntax highlighting. This extension has now been … Read more

How to implement behavior subject using service in Angular 8

I’m going to show you a simple way: @Injectable() export class ProfileService { private profileObs$: BehaviorSubject<Profile> = new BehaviorSubject(null); getProfileObs(): Observable<Profile> { return this.profileObs$.asObservable(); } setProfileObs(profile: Profile) { this.profileObs$.next(profile); } } Now when you update something anywhere in the application, you can set that change by the ProfileService and each subscriber is receiving the change. … Read more

angular 2 – adding 3rd party libs

When including 3rd party libraries, there are two parts… the javascript code you want to execute, and the definition files to give the IDE all it’s strongly-typed goodness. Obviously, the first must be present if the app is to function. The easiest way to get that is to include the 3rd party library with a … Read more

Should we use useCallback in every function handler in React Functional Components

The short answer is because arrow function is recreated every time, which will hurt the performance. This is a common misconception. The arrow function is recreated every time either way (although with useCallback subsequent ones may be thrown away immediately). What useCallback does is make it possible for the child component you use the callback … Read more

localStorage is not defined (Angular Universal)

These steps resolved my issue: Step 1: Run this command: npm i localstorage-polyfill –save Step 2: Add these two lines in server.ts file: import ‘localstorage-polyfill’ global[‘localStorage’] = localStorage; Once you are done, run build command (eg: npm run build:serverless) All set now. Start the server again and you can see the issue is resolved. Note: … Read more