Ports as words example

So I am trying to implement the same thing as this example => Words as Ports, but with a slightly different data. This example is a simple html page, but I am using Gojs in my react application. What I can’t figure out is this part right here

const ctx = document.createElement('canvas').getContext('2d'); 

My app uses the gojs ReactDiagram component, and I am not sure how I can get this 2D context in my case.
Thanks in advance

You could create a <canvas> element in your component but leave it hidden. When you need to execute this code, get the reference to the HTMLCanvasElement and call its getContext method.

Thanks, that worked for me