Skip to content

Instantly share code, notes, and snippets.

@Jobayer-Ahmed
Forked from entrptaher/problem_template.md
Last active November 19, 2017 03:33
Show Gist options
  • Save Jobayer-Ahmed/06a30f1ca1fb335ad1252b513fd8b784 to your computer and use it in GitHub Desktop.
Save Jobayer-Ahmed/06a30f1ca1fb335ad1252b513fd8b784 to your computer and use it in GitHub Desktop.
Fork the snippet below and use it to create issues. This will help debugging the issue in a better way.

Steps to reproduce

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.

  1. < h1 >{this.state.githubData.name}</ h1 >
  2. this.state = this.state.githubData.bind(this)

What is the expected result? Print My gthub profile name using github api.

What happens instead?

  1. when i add "< h1 >{this.state.githubData.name}</ h1 >" this line its gives me an error "this.state.githubData.name is undefined".
  2. 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:

  1. I copy this line "this.state is undefined" and search google they tell me to bind this.state
  2. 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

@entrptaher
Copy link

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.

@Jobayer-Ahmed
Copy link
Author

Still having same problem vai. I can convert the json data into an object and console log them but i can't grub any single element using dot notation or array notation....
Check the code.
this is the code.
and this is output
Check The error.
And here is another screenshot taken from youtube video
Youtube ScreenShot

@entrptaher

@entrptaher
Copy link

It says you did not try my solution I shared above.
On first load, there is no data in the state,
it cannot find that data.
Try the solution I shared above.

@Jobayer-Ahmed
Copy link
Author

Yap. I success to fetch api. <3 Thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment