Components Flashcards
1
Q
What must component class name begin with?
A
Capital letters
2
Q
What must a component class include?
A
- A render method
- Value for the render method should be a function
- Render method must finally include a return statement, which is usually a JSX expression
3
Q
How can you call a component’s render method?
A
ReactDOM.render(
,
document.getElementById(‘app’)
);
4
Q
Create a component that would render the following HTML code:
<blockquote> <p> What is important now is to recover our senses. </p> <cite> <a href="http://bit.ly/1LvSLUA"> Susan Sontag </a> </cite> </blockquote>
A
import React from ‘react’;
import ReactDOM from ‘react-dom’;
class QuoteMaker extends React.Component { render() { return ( <blockquote> <p> What is important now is to recover our senses. </p> <cite> <a href="http://bit.ly/1LvSLUA"> Susan Sontag </a> </cite> </blockquote> ); }
}
ReactDOM.render(
,
document.getElementById(‘app’)
);
5
Q
Create a component that would render the following HTML code:
const owl = {
title: “Excellent Owl”,
src: “https://s3.amazonaws.com/codecademy-content/courses/React/react_photo-owl.jpg”
};
A
import React from ‘react’;
import ReactDOM from ‘react-dom’;
class Owl extends React.Component { render() { return ( <div> <h1>{owl.title}</h1> <img> </div> );
}
}
ReactDOM.render(
,
document.getElementById(‘app’)
);