renderButton stops working and not showing google sign in button Angular

This was working fine until now.

ERROR in console – indicating the issue with the line with “renderButton”

enter image description here

login.component.ts

ngAfterViewInit() {
        google.accounts.id.initialize({
            client_id: 'XXXXX',
            callback: this.handleCredentialResponse.bind(this),
            auto_select: false,
            cancel_on_tap_outside: true,

        });
        
        google.accounts.id.renderButton(
            document.getElementById('google-button'),
            { theme: 'filled_blue', size: 'large', width: '215' }
        );
 }

login.component.html

<div id="google-button"></div>.

I tried:

  1. Moving the code from ngAfterViewInit to ngOnInit – it was just a try.
  2. Wrapping the code inside ngAfterViewInit to setTimeout(()=> { // here }) doesn’t work.