Skip to main content

State management with React (doc 2023)

State structuring

Principle:

  • A report must not have redundant information. Example with fullname in State vs. with a calculation of the value DURING the rendering of the component. (https://react.dev/learn/managing-state)

  • Avoid the 4 DRIC inspectors (mnemonic):

  • Duplication

    • Redundancy
    • Nesting(deep)/
    • Contradiction

Linked states (ex: x,y for position)

Useful if two or more states at the same time.

State elevation

Bonuses