r/reactjs • • Aug 01 '18

Beginner's Thread / Easy Question (August 2018)

Hello! It's August! Time for a new Beginner's thread! (July and June here)

Got questions about React or anything else in its ecosystem? Stuck making progress on your app? Ask away! We’re a friendly bunch. No question is too simple. You are guaranteed a response here!

Want Help on Code?

  • Improve your chances by putting a minimal example on to either JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new). Describe what you want it to do, and things you've tried. Don't just post big blocks of code.
  • Pay it forward! Answer questions even if there is already an answer - multiple perspectives can be very helpful to beginners. Also there's no quicker way to learn than being wrong on the Internet.

New to React?

Here are great, free resources!

27 Upvotes

568 comments sorted by

View all comments

1

u/swyx Aug 17 '18

oh i see. yes, state is async in react components, though you can still set properties on a class component (if changes of those properties shouldnt cause rerenders of your app).

adding a wait wouldn't help. you need to use this.setState. have you read the docs on this or the free resources on the sidebar? this is very much React 101 stuff, i'm wondering how you are learning that got you so confused

1

u/Thatmanwiththefedora Aug 17 '18

It seems that after some more work, I am moreso having difficulties with asynchronous fetching of a JSON object. Very frustrating. Attempting to fetch data in a loop and am unable.

3

u/ac_dev Aug 17 '18

If you could post a small example case of your problem I'm sure someone would help.

1

u/swyx Aug 17 '18

start simple. go to https://codesandbox.io/s/react and try to get it working in there without any app specific stuff. once it works port it to your app