JSFiddle - React, Tailwind, and code Playground

HTML

<div class="input_fields_wrap">
    <button class="add_field_button">Add More Fields</button>
    <div>
        <input type="text" name="mytext[]">
    </div>
</div>

JavaScript

$(document).ready(function() {
    var max_fields      = 10; //número máximo de linhas permitido
    var wrapper         = $(".input_fields_wrap"); 
    var add_button      = $(".add_field_button"); //o botão
   
    var x = 1; //contador inicial de linhas
    $(add_button).click(function(e){ //on add input button click
        e.preventDefault();
        if(x < max_fields){ //se ainda não atingiu a quantidade máxima
            x++; //cria outro textbox
            $(wrapper).append('<div><input type="text" name="mytext[]"/><a href="#" class="remove_field">Remove</a></div>'); //gera a nova linha
        }
    });
   
    $(wrapper).on("click",".remove_field", function(e){ //user click on remove text
        e.preventDefault(); $(this).parent('div').remove(); x--;
    })
});