Middle
What should not be written in the render method?
sobes.tech AI
Answer from AI
You should not write:
- Side effects: Changing application state, API calls, direct DOM manipulation.
- Business logic: Calculations, data processing, not directly related to rendering.
- Long or resource-intensive operations: Cyclic computations, complex transformations, blocking the main thread.
- Changing props or component state: Render should not modify input data.
- Direct DOM element creation: React manages the DOM, manual creation breaks its model.
The render method should be a pure function that, based on props and state, returns a UI description.