Put Logic in a render function


#1


https://www.codecademy.com/courses/react-101/lessons/react-components-advanced-jsx/exercises/render-function-calculations?action=lesson_resume

friend should be declared inside of the render function.

import React from 'react';
import ReactDOM from 'react-dom';

const friends = [
  {
    title: "Yummmmmmm",
    src: "https://s3.amazonaws.com/codecademy-content/courses/React/react_photo-monkeyweirdo.jpg"
  },
  {
    title: "Hey Guys!  Wait Up!",
    src: "https://s3.amazonaws.com/codecademy-content/courses/React/react_photo-earnestfrog.jpg"
  },
  {
    title: "Yikes",
    src: "https://s3.amazonaws.com/codecademy-content/courses/React/react_photo-alpaca.jpg"
  }
];

// New component class starts here:
class Friend extends React.Component
{
  render()
  {
    const friend=friends[0];
    return(
     <div>
      </div>
    );
  }
}<img src="//codecademy-discourse.s3.amazonaws.com/original/5X/9/0/c/b/90cb1fac06ee4c72cdf6d9b8f94462ceebb913c5.png" width="625" height="500">


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.