Created
October 2, 2022 20:38
-
-
Save ProspektsMarch22/641515f6afcd99471e52ccecf5f84810 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import { List } from './List'; | |
class App extends React.Component { | |
render() { | |
return ( | |
<div> | |
<List type='Living Musician'> | |
<li>Sachiko M</li> | |
<li>Harvey Sid Fisher</li> | |
</List> | |
<List type='Living Cat Musician'> | |
<li>Nora the Piano Cat</li> | |
</List> | |
</div> | |
); | |
} | |
} | |
ReactDOM.render( | |
<App />, | |
document.getElementById('app') | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
export class List extends React.Component { | |
render() { | |
let titleText = `Favorite ${this.props.type}`; | |
if (this.props.children instanceof Array) { | |
titleText += 's'; | |
} | |
return ( | |
<div> | |
<h1>{titleText}</h1> | |
<ul>{this.props.children}</ul> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment