Learn Before
Concept
Side Effects: (un)intended consequences in React JS
React rendering process must always be pure. Components should return the same JSX and not modify variables that exist before rendering.
Example of impure component:
let count = 0; export function Counter() { count += 1; // Bad: Can't a preexisting variable! return <h2>Counter: {count}</h2>; }
Example of pure component:
export function Counter({count}) { // This component will return same JSX return <h2>Counter: {count}</h2>; }
0
1
Updated 2023-04-18
Tags
JavaScript Programming Language
Object-Oriented Programming
Programming Language Paradigms
General programming languages
Computing Sciences