JSFiddle - React, Tailwind, and code Playground

HTML

<canvas id="c" width="800" height="600" style="border:1px solid #aaa"></canvas>

JavaScript

"use strict";

var canvas = new fabric.Canvas('c', {selection: false}),
  position = 50;

function onLabelSelection(theLabel) {
  if (theLabel.hasOwnProperty('edge')) {
    selectedEdge = theLabel.edge;
  } else {
    selectedEdge = null;
  }
}

function createLabel() {
  var label;
    
  label = new fabric.Text('Hello World', {
    left: position,
    top: position
  });
  position += 50;
    
  label.edge = null;

  label.on('selected', onLabelSelection(this));

  return label;
}

canvas.on('mouse:up', function() {
  var newLabel = createLabel(); 
  canvas.add(newLabel);
});