Skip to content

Instantly share code, notes, and snippets.

@naveennagan
Created July 19, 2019 09:27
Show Gist options
  • Save naveennagan/e6babdf039021e0fb39c8cc15426f8a6 to your computer and use it in GitHub Desktop.
Save naveennagan/e6babdf039021e0fb39c8cc15426f8a6 to your computer and use it in GitHub Desktop.
Component
import React,{Component} from 'react';
function fetchFromApi(){
//APi call
}
class NewYorkStock extends Component{
constructor(props){
this.state={
name:'NewYork'
}
}
render(){
return (
<p>
{this.state.name}
<Stock id="NYS"></Stock>
</p>
)
}
}
import React,{Component} from 'react';
function fetchFromApi(){
//APi call
}
class Stock extends Component{
constructor(props){
this.state={
value:12
}
}
componentWillMount(){
fetchFromApi((value)=>{
this.setState({
value:value
})
})
}
render(){
return (<p>{this.state.value}</p>)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment