Stateless vs stateful components
Before diving into Redux, let's do a brief recap of the differences between a stateless component and a stateful component:
- The
CodeEditor
is a stateless component written as a function. A stateless component can also be written as aclass
: that's what we did first when we write theCodeListEditor
class without callingsetState
. If a component is stateless, its appearance and behavior are fully determined by the initial props it is given. - The final
CodeListEditor
component is a stateful component: we wrote it as aclass
, we initialized the state within the constructor, and we defined some methods which use thesetState
method to update the state and trigger a re-rendering of the component.