There's honestly not a whole lot of info to go by here, but just by peaking at the code I see something I've often run into. React is funny when rendering items because it will render, then update state, and then render again. This mixed with the fact that React will just crash if anything is undefined means it will crash at the first render before it ever gets to the second render. You'll see this in your console logs if you try to log it out. There are often multiple renders in a react component and if anything is undefined in any of the renders. React will just crash.
in your case React is checking map before this.state.pictures is defined and therefore it crashes before it gets to the second render. Here's how you fix this.
- Console.log(this.state)
- If that works then console.log(this.state.pictures)
- keep going down the line until it crashes.
- at the point that is crashes make a mental note. Lets say it crashes at "this.state.pictures". You'll want to write the following code below then
this.state && this.state.pictures.map(pic)
It would take a whole textbook to explain why this works, but it does.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…