Can someone please explain why in Step 9 when creating the “removeThought” function, the call to “setThought” has to include a callback function versus just directly returning the filtered array.
This is actually a very complex subject involving understanding the underlying mechanisms of how React works. As noted in the link below, setState is an asynchronous function, so we use a callback so that when setState is called, the callback function has the updated state. Suffice to say, though, you don’t need to understand this to work with it.