What does the React pipeline look like after running JSX/code? What happens when state changes?
Asked at
AI answer
JSX is usually transformed by a bundler into React calls, and the browser executes the resulting JavaScript. During the initial render, createRoot(...).render(...) causes React to call the components and build an element tree, then reconcile it with the previous tree and create or update the DOM during the commit phase. After that, the browser calculates styles and layout, then renders the page.
When state changes, React schedules an update (often batching several updates together), recalculates the affected components, and compares the new tree with the previous one. Only the necessary changes are applied to the DOM—React does not recreate the entire page. Effects then run: useLayoutEffect before the frame is displayed, and useEffect usually after it. In concurrent mode, React can interrupt and resume work during the render phase; the commit remains atomic.
Also asked at ТрансЭнергоСнаб
- What is the difference between interface and type in TypeScript, which one do you use and why?
- What is Event Loop in JavaScript?
- Briefly tell us about yourself: what should we know about you?
- What are the advantages and disadvantages of React compared to developing in pure JavaScript? Why use React?
- What is TypeScript type guard and why is it needed?