Cannot read properties of null (reading 'length')
Hey, when stopping the app by dispatching null, the following error is thrown:
"Cannot read properties of null (reading 'length')".
It looks like the issue is caused by the following code:
if ((state = newState) == null) dispatch = subscriptions = render = id
if (subscriptions) subs = patchSubs(subs, subscriptions(state), dispatch)
When null is dispatched, the subscriptions variable becomes a reference to (a) => a.
As a result, it returns null when called with patchSubs(subs, subscriptions(state), dispatch) instead of an array (which is causing the issue)
btw, similar issue happens with view function - when app is stopped by dispatching null but then deferred render is triggered by requestAnimationFrame. At the moment render is running view is referring to (a) => a and returns null - which is causing following error at 'dom patch': "Cannot read properties of null (reading 'tag')"
The docs say, about stopping apps:
Calling the dispatch function with no arguments frees the app's resources and runs every active subscription's cleanup function.
So the right way to stop an app is not to dispatch null but to dispatch undefined. Not sure wether that makes a difference (can’t easily try at the moment)
@zaceno stopping app using undefined gives the same error:
"TypeError: Cannot read properties of undefined (reading 'tag')"
Could you make a pen with your code?
@jorgebucaran https://codepen.io/sergey-shpak/pen/dyqVbYZ (errors in console section)