Actually, you can declare styles within the render function, and there’s nothing inherently wrong with this approach. It’s same logic to defining styles directly within a DOM element’s style attribute. However, this lesson wnat to test the styles object before rendering, which is why it’s often suggested to define styles outside of the class component.
For more information, this article can be helpful in understanding different approaches to styling React components.