I sometimes have issues like null is not an object (evaluating 'localStorage.getItem') when initializing the Tagify object on my page, and, based on the stacktrace, it is caused by this logic: {snip} |{},this.getPersistedData=(s=e.id,function(t){var e,i="/"+t;if(1==localStorage.getItem(j+s+"/v",1))try{e=JSON.parse(localStorage[j+s+i])}cat {snip}
I see in your code in setPersistedData that you check if id is passed, and if it doesn't exist, return: if( !id ) return () => {};
I would assume, it would be useful to have the same logic in getPersistedData as well, and not try to access localStorage if the id is not passed. Is there a reason why this check is absent in getPersistedData? Would it be possible to add it?
I don't pass the ids in my code and don't need the persisted data functionality, it's just that sometimes my users' devices don't give permission to access localStorage, and I would like to avoid getting errors.
Hello!
I sometimes have issues like
null is not an object (evaluating 'localStorage.getItem')
when initializing the Tagify object on my page, and, based on the stacktrace, it is caused by this logic:{snip} |{},this.getPersistedData=(s=e.id,function(t){var e,i="/"+t;if(1==localStorage.getItem(j+s+"/v",1))try{e=JSON.parse(localStorage[j+s+i])}cat {snip}
I see in your code in
setPersistedData
that you check ifid
is passed, and if it doesn't exist, return:if( !id ) return () => {};
I would assume, it would be useful to have the same logic ingetPersistedData
as well, and not try to access localStorage if theid
is not passed. Is there a reason why this check is absent ingetPersistedData
? Would it be possible to add it?I don't pass the ids in my code and don't need the persisted data functionality, it's just that sometimes my users' devices don't give permission to access localStorage, and I would like to avoid getting errors.
Thanks!