@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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,24 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.3.19](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@2.3.18...@contentful/field-editor-rich-text@2.3.19) (2022-08-10)
7
+
8
+ ### Bug Fixes
9
+
10
+ - update hooks deps in useFetchedEntity [TOL-339] ([#1212](https://github.com/contentful/field-editors/issues/1212)) ([02ae9be](https://github.com/contentful/field-editors/commit/02ae9be167bea5876d52db27a4363a69bdfc6209))
11
+
12
+ ## [2.3.18](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@2.3.17...@contentful/field-editor-rich-text@2.3.18) (2022-08-10)
13
+
14
+ ### Bug Fixes
15
+
16
+ - check store in entity fetch ([#1211](https://github.com/contentful/field-editors/issues/1211)) ([3ddc0b2](https://github.com/contentful/field-editors/commit/3ddc0b2d3ffc2e2146cb8f0ee07d540cb875b717))
17
+
18
+ ## [2.3.17](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@2.3.16...@contentful/field-editor-rich-text@2.3.17) (2022-08-09)
19
+
20
+ ### Bug Fixes
21
+
22
+ - version compare webapp ([#1210](https://github.com/contentful/field-editors/issues/1210)) ([bbe0882](https://github.com/contentful/field-editors/commit/bbe0882f15d771dc713c688f8ba4df0be8c13102))
23
+
6
24
  ## [2.3.16](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@2.3.15...@contentful/field-editor-rich-text@2.3.16) (2022-08-09)
7
25
 
8
26
  **Note:** Version bump only for package @contentful/field-editor-rich-text
@@ -2160,7 +2160,9 @@ function useFetchedEntity(_ref) {
2160
2160
  getEntry = _useEntities.getEntry,
2161
2161
  getAsset = _useEntities.getAsset;
2162
2162
 
2163
- var store = type === 'Entry' ? entries : assets;
2163
+ var store = React.useMemo(function () {
2164
+ return type === 'Entry' ? entries : assets;
2165
+ }, [assets, entries, type]);
2164
2166
 
2165
2167
  var _useState = React.useState(store == null ? void 0 : store[id]),
2166
2168
  entity = _useState[0],
@@ -2168,6 +2170,10 @@ function useFetchedEntity(_ref) {
2168
2170
 
2169
2171
 
2170
2172
  React.useEffect(function () {
2173
+ if (!store) {
2174
+ return;
2175
+ }
2176
+
2171
2177
  var newValue = store[id];
2172
2178
 
2173
2179
  if (!areEqual(entity, newValue)) {
@@ -2176,12 +2182,16 @@ function useFetchedEntity(_ref) {
2176
2182
  }, [store, entity, id]); // Fetch the entity if needed
2177
2183
 
2178
2184
  React.useEffect(function () {
2185
+ if (!store) {
2186
+ return;
2187
+ }
2188
+
2179
2189
  (type === 'Entry' ? getEntry : getAsset)(id); // "getEntry" and "getAsset" instances change with every
2180
2190
  // entity store update causing page lag on initial load
2181
2191
  // TODO: consider rewriting useEntities() hook to avoid that happening in
2182
2192
  // first place.
2183
2193
  // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: explain this disable
2184
- }, [type, id]);
2194
+ }, [type, id, store]);
2185
2195
  React.useEffect(function () {
2186
2196
  if (entity) {
2187
2197
  onEntityFetchComplete == null ? void 0 : onEntityFetchComplete();