Skip to content

Instantly share code, notes, and snippets.

@yokesharun
Last active February 15, 2019 14:53
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 yokesharun/171666ee8318d63c10eab4f9a9654465 to your computer and use it in GitHub Desktop.
Save yokesharun/171666ee8318d63c10eab4f9a9654465 to your computer and use it in GitHub Desktop.
A Simple Example of React Parent - Child Component
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