title: Calculate pixel width of text without knowing font in React/JavaScript
body: <p>I need to measure the pixel length of individual words (strings) in a container. I am shrinking each div's width so when the text wraps it is perfectly flush against its container, as there is a max-width that causes it to wrap. This solution (and its use case) have previously been answered in Jquery on this answer:</p>
  
  <p><a href="https://stackoverflow.com/questions/14596213/shrink-div-to-text-thats-wrapped-to-its-max-width/14597951#14597951">Shrink DIV to text that&#39;s wrapped to its max-width?</a></p>
  
  <p>However, the above solution places each word in a span and uses Jquery's .width() method to calculate its physical size. As I am using React, I do not have this option. </p>
  
  <p>While I have been successful in using the offsetWidth method to find the width of an item that has been rendered to the DOM, I have not found other viable solutions that don't involve rendering the item to the dom I can use to find the width of a single world.</p>
  
  <p>Some solutions I have found online provide methods that factor in the font, but the font could change, so I need a method more like Jquery's .width(). </p>
  
  <p>Does React/JavaScript (not Jquery) have any means of determining the physical length of a word in pixels without having to render the item to the dom and without putting the font type into a function? </p>