My component was rendering perfectly fine, but when I added the last two properties to the element, the component stopped rendering properly. I tested it by typing one part at a time, and it seems like it renders perfectly fine until I add a number in the bracket to pull an element out, in my case Math.floor(Math.random() * 3). I tried using a simple int as well, but it didn’t like that either.
You’re referencing the state inside the state and it’ll break. What does this refer to when it’s inside the state? Unless you’re extremely confident about how React, internally, deals with updating and referencing that object, it’s not going to be safe to then add another layer of internal references to it.
No, for class components you use the componentDidMount lifecycle method: component initialises >> that method is called >> in it you can set the state.