InterviewSolution
| 1. |
Explain the initial cycle in React which happens during the first render? |
|
Answer» When a React App loads for the first time, the code is RUN in the mentioned order. All the below-mentioned methods run only one time except “render()”, which can be run many times depending on setState and Parent component bee called.
3) Then the initial “render()” will be called. It will also render all the child components(if any) of this component. Also, note that render is generally called many times. WHENEVER we use setState, the component render is called. 4) Then the function “componentDidMount()” will be called. This function will also be called once during the whole life-cycle. It is a great place to do AJAX call to the server to fetch some data. You can also initialize something that requires interaction with the DOM, like a jQuery library. |
|