title: React: Calling a function inside a map function
body: <p>Here's the basic layout of the object I'm using (being passed as a prop to the component): </p>
  
  <pre><code>bigObject {
      overview: {
          *not being used for current concern*
      },
      code: {
          1: {
              textArray: [*array of length 4 to 8*],
              imgSrc: "string goes here"
          },
          2: {
              textArray: [*array of length 4 to 8*],
              imgSrc: "string goes here"
          },
          3: {
              textArray: [*array of length 4 to 8*],
              imgSrc: "string goes here"
          },
      }
  }
  </code></pre>
  
  <p>My constructor: </p>
  
  <pre><code>constructor(props) {
      super(props);
      this.state = {
          projectName: this.props.projectName,
          info: bigObject[this.props.projectName]
      }
      this.renderInfo = this.renderInfo.bind(this);
      this.renderText = this.renderText.bind(this);
  
      console.log(this.state.info);
  }
  </code></pre>
  
  <p>What I'm trying to do is iterate through the code object so that for each imgSrc, the text array in the object with it is iterated over to create list elements along side the photo. </p>
  
  <pre><code>renderInfo() {
      return Object.keys(this.state.info.code).map(function(key, index) {
          return (
              &lt;div className="code-snippet" id={name + key} key={key}&gt;
                  &lt;div className="code-description"&gt;
                      &lt;ul&gt;
                          {() =&gt; this.renderText(key)}
                      &lt;/ul&gt;
                  &lt;/div&gt;
                  &lt;div className="code-img"&gt;
                      &lt;img src={"/project-images/MongoScraper/" + placeholder[key].img} alt=""/&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          )
      });
  }
  </code></pre>
  
  <p>Each img is rendered exactly how I want, but the renderText method isn't iterating through the textArray like I want:</p>
  
  <pre><code>renderText(key) {
      console.log("hello world") //doesn't log
      let placeholder = this.state.info.code;
      return placeholder[key].text.map(function(keyValue, index) {
          return (
              &lt;li&gt;{placeholder[key].text[index]}&lt;/li&gt;
          )
      });
  }
  </code></pre>
  
  <p>The render() method: </p>
  
  <pre><code>render() {
      return (
          &lt;div className="container code-descriptor-div"&gt;
              {this.renderInfo()}
          &lt;/div&gt;
      )
  }
  </code></pre>
  
  <p>I'm using an arrow function when I call the renderText method because of lexical scoping concerns ("cannot read property of undefined" results from not using the arrow function), but I know the method isn't being called at all because the console isn't logging "Hello world". </p>
  
  <p>When I call the renderText method inside of the render() method, it will render the list elements properly, but doing that doesn't work with how I'm structuring other components.</p>
  
  <p>Is there a way to iterate through the textArray like I want? </p>