@contentful/field-editor-rich-text 2.3.16 → 2.3.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2153,7 +2153,9 @@ function useFetchedEntity(_ref) {
2153
2153
  getEntry = _useEntities.getEntry,
2154
2154
  getAsset = _useEntities.getAsset;
2155
2155
 
2156
- var store = type === 'Entry' ? entries : assets;
2156
+ var store = useMemo(function () {
2157
+ return type === 'Entry' ? entries : assets;
2158
+ }, [assets, entries, type]);
2157
2159
 
2158
2160
  var _useState = useState(store == null ? void 0 : store[id]),
2159
2161
  entity = _useState[0],
@@ -2161,6 +2163,10 @@ function useFetchedEntity(_ref) {
2161
2163
 
2162
2164
 
2163
2165
  useEffect(function () {
2166
+ if (!store) {
2167
+ return;
2168
+ }
2169
+
2164
2170
  var newValue = store[id];
2165
2171
 
2166
2172
  if (!areEqual(entity, newValue)) {
@@ -2169,12 +2175,16 @@ function useFetchedEntity(_ref) {
2169
2175
  }, [store, entity, id]); // Fetch the entity if needed
2170
2176
 
2171
2177
  useEffect(function () {
2178
+ if (!store) {
2179
+ return;
2180
+ }
2181
+
2172
2182
  (type === 'Entry' ? getEntry : getAsset)(id); // "getEntry" and "getAsset" instances change with every
2173
2183
  // entity store update causing page lag on initial load
2174
2184
  // TODO: consider rewriting useEntities() hook to avoid that happening in
2175
2185
  // first place.
2176
2186
  // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: explain this disable
2177
- }, [type, id]);
2187
+ }, [type, id, store]);
2178
2188
  useEffect(function () {
2179
2189
  if (entity) {
2180
2190
  onEntityFetchComplete == null ? void 0 : onEntityFetchComplete();