title: Reusable Button with Image
body: <p>So i'm new to react native and javascript, and i want to make a reusable button with image and i found this code </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import React from 'react';
  import { Image, TouchableOpacity } from 'react-native';
  
  const ImgButtons = ({ onPress, img }) =&gt; {
  
  return (
    &lt;TouchableOpacity onPress={onPress}&gt;
      &lt;Image
        source={require(img)}
      /&gt;
    &lt;/TouchableOpacity&gt;
    );
  };
  
  export { ImgButtons };</code></pre>
  </div>
  </div>
  </p>
  
  <p>and i call the component</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code> &lt;View style={styles.innerContainer}&gt;
          &lt;ImgButtons
             img={require('../assets/btn-reg-1.jpg')}/&gt;
    &lt;/View&gt; </code></pre>
  </div>
  </div>
  </p>
  
  <p>i got an error say  Error: component/ImgButtons.js:Invalid call at line 9: require(img)</p>
  
  <p>can somebody help me? Thanks :)</p>