Scope | Needs to trigger rerender on change | Mutability | You should use... |
---|---|---|---|
Local | No/never changes | Any | Local constants/variables |
Local | Yes | (Locally) Immutable | Props |
Local | Yes | Mutable | State |
Global | No/never changes | Any | Constants/variables in a module, imported where required |
Global | Yes | Mutable | Context |
The table has a theoretical gap in the "global, should trigger rerender, immutable" row, but if it's globally immutable then it'll never change, and thus rerendering is moot (i.e. it can just live in a module).
Local/global aren't very strict here. They loosely mean "relevant to this component + a small neighborhood" and "relevant to many unrelated pieces of code" respectively.