Skip to content

Instantly share code, notes, and snippets.

@hoangthau
Last active December 26, 2018 01:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hoangthau/c3e1b3bd1e09b267ac7cb6e8fe90f871 to your computer and use it in GitHub Desktop.
Save hoangthau/c3e1b3bd1e09b267ac7cb6e8fe90f871 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
// Family chỉ làm nhiệm vụ trung chuyển props cho Person
const Family = (props) => (
<div className="family">
<Person info={props.person} />
</div>
)
class Person extends Component {
render() {
const { age, name } = this.props;
return (
<div className="person">
<p>Age: {age}</p>
<p>Name: {name}</p>
</div>
)
}
}
class App extends Component {
state = {
name: "Dan",
age: 28
};
render() {
return (
<div>
<p>This is a demo that we do not use Context API</p>
<Family person={this.state} />
</div>
);
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment