CONTACT US

    Why do I need Keys in React Lists?

    • Lists are performant heavy and need to be used carefully.
    • Make sure every item in the list has a unique key.
    • It is preferred to not use indexes as a key unless you know for sure that the list is a static list (no additions/re-ordering/removal to the list).
    • Never use unstable keys like Math.random() to generate a key.
    • React will run into performance degradation and unexpected behavior if unstable keys are used.

    Article link copied

    Close button