Skip to content

useSelector returning out-of-date resultΒ #1316

@hednowley

Description

@hednowley

What is the current behavior?

See this sandbox.

After deleting an entry, useSelector in the ListHook component returns an out-of-date result including the ID of the deleted entry. This leads to an Item calling useSelector for the missing item (this is logged to the console). It looks to me like it might be because the selector is run inside an effect hook.

The ListClass component uses the old connect approach and doesn't have the same issue.

What is the expected behavior?

The behaviour of the hook has caused some issues while migrating an app where selectors currently throw exceptions. I understand the hook isn't meant to be a drop-in replacement for the old approach but I'm interested to see if there is a way to avoid this while still using hooks.

Which versions of React, ReactDOM/React Native, Redux, and React Redux are you using? Which browser and OS are affected by this issue? Did this work in previous versions of React Redux?

react 16.8.6
react-dom 16.8.6
react-redux 7.1.0
redux 4.0.1

Issue exists in all 7.1.0 alphas and RC.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions