Skip to content

Instantly share code, notes, and snippets.

@johnloven
Last active March 16, 2018 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnloven/eb52e414a3fe71cf17aa50435182002e to your computer and use it in GitHub Desktop.
Save johnloven/eb52e414a3fe71cf17aa50435182002e to your computer and use it in GitHub Desktop.
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