Components Flashcards

1
Q

What must component class name begin with?

A

Capital letters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How can you call a component’s render method?

A

ReactDOM.render(
,
document.getElementById(‘app’)
);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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’)
);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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’)
);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly