title: React Native: require() with Dynamic String?
body: <p>I have read several posts about issues that people are having with React Native and the <code>require()</code> function when trying to require a dynamic resource such as:</p>
  
  <p>Dynamic <strong>(fails)</strong>:</p>
  
  <pre><code>urlName = "sampleData.json";
  data = require('../' + urlName);
  </code></pre>
  
  <p>vs. Static <strong>(succeeds)</strong>:</p>
  
  <pre><code>data = require('../sampleData.json');
  </code></pre>
  
  <p>I have read on some threads that this is a bug in React Native and in others that this is a feature.</p>
  
  <p>Is there a new way to require a dynamic resource within a function?</p>
  
  <p>Related Posts (all fairly old in React time):</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/33085341/importing-text-from-local-json-file-in-react-native">Importing Text from local json file in React native</a></li>
  <li><a href="https://stackoverflow.com/questions/39901584/react-native-dynamically-list-require-files-in-directory">React Native - Dynamically List/Require Files In Directory</a></li>
  <li><a href="https://stackoverflow.com/questions/30854232/react-native-image-require-module-using-dynamic-names">React Native - Image Require Module using Dynamic Names</a></li>
  <li><a href="https://stackoverflow.com/questions/43516269/react-native-how-to-use-requirepath-with-dynamic-urls">React Native: how to use require(path) with dynamic urls?</a></li>
  </ul>