Created
July 19, 2019 09:27
-
-
Save naveennagan/e6babdf039021e0fb39c8cc15426f8a6 to your computer and use it in GitHub Desktop.
Component
This file contains 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'; | |
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> | |
) | |
} | |
} |
This file contains 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'; | |
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