Every component in React goes through a lifecycle of events. You can think is of going through a cycle of…