Commit e12855cc authored by Kristian Freeman's avatar Kristian Freeman

Answer key - nesting components

parent cdd28be4
import React from 'react';
import ReactDOM from 'react-dom';
var PROP_TEXT_HERE;
// No changes are needed above this line.
import React from "react";
import ReactDOM from "react-dom";
class MyApp extends React.Component {
render() {
// Instead of a span below, try using
// MyComponent, as well as passing a name prop.
return (
<div>
<span>Placeholder</span>
<MyComponent name="John Smith" />
</div>
);
}
......@@ -19,14 +13,10 @@ class MyApp extends React.Component {
class MyComponent extends React.Component {
render() {
// Replace PROP_TEXT_HERE with the
// `name` prop passed in to the component.
// Remember to define a name variable, using
// the value from `this.props`.
const { name } = this.props;
return (
<div>
<span>{PROP_TEXT_HERE}</span>
<span>{name}</span>
</div>
);
}
......@@ -34,9 +24,9 @@ class MyComponent extends React.Component {
// No changes are needed below this line.
const root = document.getElementById('root');
const root = document.getElementById("root");
if (root) {
ReactDOM.render(<MyApp />, root);
}
export {MyApp, MyComponent};
export { MyApp, MyComponent };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment