Canvas in ionic 4

Hello,

I used ionic 3 with a canvas to make a plan and I switched to ionic 4, only I can not use canvas with ionic 4, but I use the same code.

Below, I just put the code that allowed to create the canvas. (This code works for ionic 3 but not for ionic 4).
In the .ts :
import { Component, ElementRef, ViewChild } from ‘@angular/core’;

@Component({
selector: ‘app-tab2’,
templateUrl: ‘tab2.page.html’,
styleUrls: [‘tab2.page.scss’]
})
export class Tab2Page {

@ViewChild(‘canvas’) canvasEl : ElementRef;
private _CANVAS : any;
private _CONTEXT : any;

constructor(){}

ionViewDidLoad() : void
{
   this._CANVAS 		    = this.canvasEl.nativeElement;
   this._CANVAS.width  	= 500;
   this._CANVAS.height 	= 500;

   this.setupCanvas();
}


setupCanvas() : void
{
  this._CONTEXT = this._CANVAS.getContext('2d');
  this._CONTEXT.clearRect(0, 0, this._CANVAS.width, this._CANVAS.height);
  this._CONTEXT.fillStyle = "#ff0000";
  this._CONTEXT.fillRect(100, 100, 400, 400);
}

}

In the .html :
<ion-content>
<div class=“ion-canvas”>
<canvas #canvas></canvas>
</div>
</ion-content>

Thank you in advance for your help

Have you tried changing ionViewDidLoad to ionViewDidEnter?
I think that is all you need.