Last active
March 16, 2018 18:30
-
-
Save johnloven/eb52e414a3fe71cf17aa50435182002e 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
class App extends React.Component { | |
render() { | |
return ( | |
<div> | |
<StudentContainer/> | |
<OtherContainer/> | |
<AndAnotherContainer/> | |
<div> | |
); | |
} | |
} | |
class StudentContainer extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { students: [] }; | |
} | |
componentDidMount() { | |
fetch("myschool.com/students") | |
.then(response => response.json()) | |
.then(json => this.setState({ students: json })); | |
} | |
render() { | |
return <StudentPage students={this.state.students}/>; | |
} | |
} | |
class StudentPage extends React.Component { | |
render() { | |
return ( | |
<div> | |
{this.props.students.map(student => <div>student.name</div>)} | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment