Guest User

Untitled

a guest
Dec 12th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. class App extends Component {
  2. constructor(props) {
  3. super(props);
  4. this.state = {};
  5. }
  6.  
  7. static defaultProps = {
  8. value: "test"
  9. };
  10.  
  11. static propTypes = {
  12. value: PropTypes.string
  13. };
  14.  
  15. static childContextTypes = {
  16. color: PropTypes.string
  17. }
  18.  
  19. getChildContext() {
  20. return { color: "gray" };
  21. }
  22.  
  23. componentWillMount(nexProps, nexState) {}
  24. // use setState
  25. componentDidMount() {}
  26. // use setState
  27. componentWillReceiveProps(nextProps, nextState) {}
  28.  
  29. componentWillUpdate(nextProps, nextState) {}
  30.  
  31. componentWillUnmount() {}
  32.  
  33. render() {
  34. return (
  35. <div>
  36. {this.props.value}
  37. <Children />
  38. </div>
  39. );
  40. }
  41. }
  42.  
  43. class Children extends Component {
  44. constructor(props, context) {
  45. super(props);
  46. this.state = {};
  47. }
  48.  
  49. static contextTypes = {
  50. color: PropTypes.string
  51. };
  52.  
  53. render() {
  54. return (
  55. <div>{this.props.color}</div>
  56. )
  57. }
  58. }
  59.  
  60. render(<App />, document.getElementById("root"));
Add Comment
Please, Sign In to add comment