Skip to main content

Glossary

Side Effect

A function is said to have a side effect if it tries to modify anything outside its body. That is:

  • modifying a global variable or a variable in a parent scope chain (not own scope)
  • executing an http-call
  • writing to screen or file

Pure Function

A pure function is deterministic and idempotent, meaning every invocation of the function with a specific input will always produce the same outcome.

Reducer

A reducer is a function that manages changes to an object. It takes the following two arguments:

  • state: the current state (object)
  • action: object that describes the state update ({ type: string, payload: object })

So based on the second argument we perform a certain update to create a new state, which we return in our reducer function. The first argument never gets changed. And the reducer function must always return something.

Unidirectional Data Flow

Data can only flow in one direction, namely from parent to child in the form of immutable props.

Controlled Component

A component which has its state managed by React. E.g. an input-element has its own state by default (in the DOM). So by default it is an uncontrolled component. To make it a controlled component we need to wire it up with the component state of react (either this.state or useState), so that each change is written into the component state and the component gets its value from that component state.

React Refs

Gives you access to a single DOM element. This is kind of Reacts way of document.querySelector.