jorgebucaran/hyperapp

TypeError: can't access property 0, newSubs is null, when setting the state to undefined.

teehemkay opened this issue · 4 comments

Setting the state to undefined (per the Stopping your app section in the docs) triggers a type error.

The issue seems to come from the following line:

if ((state = newState) == null) dispatch = subscriptions = render = id

When the subscriptions function is replaced with the id identify function and the state is undefined, the subscriptions function will thus return undefined instead of returning an array as expected by the patchSubs function.

Upon further investigation, I don't think my assumptions above are correct: normally, patchSubs should catch the undefined subscriptions array and replace it with an EMPTY_ARR at call time.:

var patchSubs = (oldSubs, newSubs = EMPTY_ARR, dispatch) => {

I'll keep digging and report back ASAP.

OK, the issue was not with hyper app but rather with my code: the state was set to null instead ofundefined resulting in the default EMPTY_ARR not being used at call time.

I apologized for the erroneous issue report.

Thanks for clearing that up.

BTW, thank you so much for hyperapp. It's so exquisitely designed and the code is a joy to read.