Last active
February 15, 2019 14:53
-
-
Save yokesharun/171666ee8318d63c10eab4f9a9654465 to your computer and use it in GitHub Desktop.
A Simple Example of React Parent - Child Component
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, { Component } from 'react'; | |
Class ParentComponent extends Component{ | |
this.state = { | |
title: "CodeFights", | |
description: "Online website" | |
} | |
constructor(props){ | |
super(props); | |
} | |
render(){ | |
return ( | |
<div> | |
<p>Title : {this.state.title}<p> | |
<ChildComponent description={this.state.description} /> | |
</div> | |
) | |
} | |
} | |
Class ChildComponent extends Component{ | |
render(){ | |
return ( | |
<p>Description : {this.props.description}</p> | |
) | |
} | |
} | |
// OUTPUT | |
// Title : CodeFights | |
// Description : Online website |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment