Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

React Native - You attempted to set the key with the value on an object that is meant to be immutable and has been frozen

$
0
0

If I attempt to set a previously defined memoized value to a list of values of length one, no error throws. If I set it to a list of length > 2 I get the following error

Error: You attempted to set the key `0` with the value `"acmemarkets"` on an object that is meant to be immutable and has been frozen.

SelectedStores is a value stored in a context - Relevant example code

  const logAnalyticsEvent = useCallback(    (feelingHungryActionType: FeelingHungryActionType) => {      logFeelingHungryAction({        feelingHungryActionType,        dietId: dietId ?? null,        productUpcBeingViewed: currentProduct?.upc ?? null,        selectedStores: selectedStores ?? [StoreNames.BrowseAllStores],        greenOnly,        feelingHungryAfterLikeAutoCloseDelayInMs,        feelingHungryHowManyProductsToKeepInPreloadBuffer,        feelingHungryHowManyProductsToLoadPerRequest,      });    },    [      dietId,      currentProduct,      selectedStores,      greenOnly,      feelingHungryAfterLikeAutoCloseDelayInMs,      feelingHungryHowManyProductsToKeepInPreloadBuffer,      feelingHungryHowManyProductsToLoadPerRequest,      logFeelingHungryAction,    ],  );

If I change this to simply return a copy of selectedStores using

selectedStores.map(store=>store)

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>