Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Intermittent undefined state when a reducer is re-attached. #425

Closed
n-mcnally opened this issue Oct 29, 2020 · 3 comments
Closed

Intermittent undefined state when a reducer is re-attached. #425

n-mcnally opened this issue Oct 29, 2020 · 3 comments

Comments

@n-mcnally
Copy link

n-mcnally commented Oct 29, 2020

Is it a bug, feature request or question?

Bug

Which package(s) does this involve?

[@redux-dynostore/core, @redux-dynostore/react-redux]

Input Code

This implementation uses a simple withReducer HOC to attach and detach the provided reducers with the component.

Code Sandbox

Expected Behaviour

When a component using withReducer is mounted the reducers should be attached then detached once unmounted.

Current Behaviour

A small percentage of the time when re-attaching the reducer the state becomes undefined and causes the selectors to throw an error.

Cannot read property 'value' of undefined

After further investigation this issue only occurs whilst the Redux Devtools plugin is enabled.

Context

Parts of our app (data tables, grids) require large state trees and are rarely used more than once so would benefit from a reusable HOC for detaching the reducer once the component unmounts.

Your Setup

Package Name Version
React 17.0.1
@redux-dynostore/core ^3.1.0
@redux-dynostore/react-redux ^3.1.0
redux-dev-tools 2.17.0
@mpeyper
Copy link
Contributor

mpeyper commented Nov 10, 2020

Hi @n-mcnally,

Can you please confirm if this is still an issue? The sandbox appears to be working as I'd expect.

@n-mcnally
Copy link
Author

n-mcnally commented Nov 10, 2020

Hi @mpeyper,

Thanks for having a look! I've just gave it another go and can confirm the problem is still occurring.

It typically works as expected the first time the reducer is attached/detached but then when it's re-attached i get the bug causing the undefined state in the selectors.

I have also confirmed in our own app that this only occurs when the Redux Devtool extention is enabled, if that's any use.

@mpeyper
Copy link
Contributor

mpeyper commented Jan 27, 2021

Closing. Please see #484 for details.

@mpeyper mpeyper closed this as completed Jan 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants