Skip to content

Examples should show best practice choosing scope where selectors are created  #95

@cefn

Description

@cefn

Examples should demonstrate best practice with scope of selector creation..

Looking at e.g. the following line...

const counter = useSelected(counterStore, (state) => state.counter);

...the selector is recreated on every render. This goes against advice from the docs.

Although this doesn't create more renders, the render is doing more work than necessary, since the evaluation of the (new) selector can't be skipped, which could be skipped if the selector reference remained unchanged (e.g. was created with module scope).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions