Can we implement this method however we like?

Question

In the context of this exercise, covering shouldComponentUpdate, can we implement these lifecycle methods however we like?

Answer

In general, yes, you can override the code within the lifecycle methods to run however you like. You can think of the component lifecycle methods as the steps that are followed during the lifecycle of a component, but for which the implementations of each step are not constrained to one implementation.

However, it is important to keep in mind that some methods do require certain values to be returned. For instance, shouldComponentUpdate should return a boolean value, either true or false.

5 Likes