Tell us about your environment:
- Software/Script version: create-react-app
- Platform / OS version: linux 64 bit
- URLs (if applicable): Nai.
What steps will reproduce the problem?
Please include code that reproduces the issue.
- < h1 >{this.state.githubData.name}</ h1 >
- this.state = this.state.githubData.bind(this)
What is the expected result? Print My gthub profile name using github api.
What happens instead?
- when i add "< h1 >{this.state.githubData.name}</ h1 >" this line its gives me an error "this.state.githubData.name is undefined".
- when i open react dev tool. there is a option called state. and there store all my github data story. but it doesent print using state.
Internet Search Result:
- I copy this line "this.state is undefined" and search google they tell me to bind this.state
- when i bind this.state like this "this.state = this.state.githubData.bind(this);" then i got an new error "TypeError: _this.state.githubDada is undefined".
Github Repository: https://github.com/Jobayer-Ahmed/ReactGithubAPI
And,
<h1>{this.state.githubData.name}</h1>
You can do something like this,
<h1>{this.state.githubData ? this.state.githubData.name : "" }</h1>
It would check if there is githubData, if not then it won't print anything.