Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

create a friend component react js

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


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

// New component class starts here:
class Friend extends React.Component {
  render() {
    const friend = friends[0];
    return (
      <div>
      <h1>{friend.title}</h1>
      <img 
        src={friend.src}
      />
      </div>
    );
  }
}

ReactDOM.render(
  <Friend />,
  document.getElementById('app')
);
 
PREVIOUS NEXT
Tagged: #create #friend #component #react #js
ADD COMMENT
Topic
Name
7+3 =