ioof-holdings / redux-dynostore

These libraries provide tools for building dynamic Redux stores.
BSD 3-Clause "New" or "Revised" License
122 stars 15 forks source link

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

Closed n-mcnally closed 3 years ago

n-mcnally commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

Closing. Please see #484 for details.