JSFiddle - React, Tailwind, and code Playground

HTML

<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<input type="text" id="firstname">

JavaScript

/******jquery********/
$(document).ready(function(){
   $("#firstname").change(function(){
      var text=$(this).val();
      $(this).val(text.replace(/\s/g,''));
   });
});