@contentful/field-editor-reference 5.30.6 → 5.30.8

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.
@@ -107,7 +107,7 @@ function SingleReferenceEditor(props) {
107
107
  return _react.createElement(Editor, {
108
108
  ...props,
109
109
  key: `${externalReset}-reference`,
110
- entityId: value ? value.sys.id : '',
110
+ entityId: value ? value?.sys?.id : '',
111
111
  isDisabled: disabled,
112
112
  setValue: setValue,
113
113
  allContentTypes: allContentTypes
@@ -64,17 +64,25 @@ function useScheduledActions({ getEntityScheduledActions, entityId, entityType }
64
64
  type: 'loading'
65
65
  });
66
66
  _react.useEffect(()=>{
67
+ let mounted = true;
67
68
  getEntityScheduledActions(entityType, entityId).then((data)=>{
68
- setStatus({
69
- type: 'loaded',
70
- jobs: data
71
- });
69
+ if (mounted) {
70
+ setStatus({
71
+ type: 'loaded',
72
+ jobs: data
73
+ });
74
+ }
72
75
  }).catch((e)=>{
73
- setStatus({
74
- type: 'error',
75
- error: e
76
- });
76
+ if (mounted) {
77
+ setStatus({
78
+ type: 'error',
79
+ error: e
80
+ });
81
+ }
77
82
  });
83
+ return ()=>{
84
+ mounted = false;
85
+ };
78
86
  }, []);
79
87
  if (status.type === 'loading') {
80
88
  return {
@@ -65,6 +65,7 @@ function WrappedEntryCard(props) {
65
65
  const [file, setFile] = _react.useState(null);
66
66
  const { contentType } = props;
67
67
  _react.useEffect(()=>{
68
+ let mounted = true;
68
69
  if (props.entry) {
69
70
  getEntryImage({
70
71
  entry: props.entry,
@@ -72,11 +73,18 @@ function WrappedEntryCard(props) {
72
73
  localeCode: props.localeCode,
73
74
  defaultLocaleCode: props.defaultLocaleCode
74
75
  }, props.getAsset).then((file)=>{
75
- setFile(file);
76
+ if (mounted) {
77
+ setFile(file);
78
+ }
76
79
  }).catch(()=>{
77
- setFile(null);
80
+ if (mounted) {
81
+ setFile(null);
82
+ }
78
83
  });
79
84
  }
85
+ return ()=>{
86
+ mounted = false;
87
+ };
80
88
  }, [
81
89
  props.entry,
82
90
  props.getAsset,
@@ -57,7 +57,7 @@ export function SingleReferenceEditor(props) {
57
57
  return React.createElement(Editor, {
58
58
  ...props,
59
59
  key: `${externalReset}-reference`,
60
- entityId: value ? value.sys.id : '',
60
+ entityId: value ? value?.sys?.id : '',
61
61
  isDisabled: disabled,
62
62
  setValue: setValue,
63
63
  allContentTypes: allContentTypes
@@ -5,17 +5,25 @@ export function useScheduledActions({ getEntityScheduledActions, entityId, entit
5
5
  type: 'loading'
6
6
  });
7
7
  React.useEffect(()=>{
8
+ let mounted = true;
8
9
  getEntityScheduledActions(entityType, entityId).then((data)=>{
9
- setStatus({
10
- type: 'loaded',
11
- jobs: data
12
- });
10
+ if (mounted) {
11
+ setStatus({
12
+ type: 'loaded',
13
+ jobs: data
14
+ });
15
+ }
13
16
  }).catch((e)=>{
14
- setStatus({
15
- type: 'error',
16
- error: e
17
- });
17
+ if (mounted) {
18
+ setStatus({
19
+ type: 'error',
20
+ error: e
21
+ });
22
+ }
18
23
  });
24
+ return ()=>{
25
+ mounted = false;
26
+ };
19
27
  }, []);
20
28
  if (status.type === 'loading') {
21
29
  return {
@@ -14,6 +14,7 @@ export function WrappedEntryCard(props) {
14
14
  const [file, setFile] = React.useState(null);
15
15
  const { contentType } = props;
16
16
  React.useEffect(()=>{
17
+ let mounted = true;
17
18
  if (props.entry) {
18
19
  getEntryImage({
19
20
  entry: props.entry,
@@ -21,11 +22,18 @@ export function WrappedEntryCard(props) {
21
22
  localeCode: props.localeCode,
22
23
  defaultLocaleCode: props.defaultLocaleCode
23
24
  }, props.getAsset).then((file)=>{
24
- setFile(file);
25
+ if (mounted) {
26
+ setFile(file);
27
+ }
25
28
  }).catch(()=>{
26
- setFile(null);
29
+ if (mounted) {
30
+ setFile(null);
31
+ }
27
32
  });
28
33
  }
34
+ return ()=>{
35
+ mounted = false;
36
+ };
29
37
  }, [
30
38
  props.entry,
31
39
  props.getAsset,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-reference",
3
- "version": "5.30.6",
3
+ "version": "5.30.8",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -64,5 +64,5 @@
64
64
  "publishConfig": {
65
65
  "registry": "https://npm.pkg.github.com/"
66
66
  },
67
- "gitHead": "c29381bb6d6228af3c126376d9e9218ecfc7d1bb"
67
+ "gitHead": "5fe891575a72781c1166b26d69506e9d100e5c4f"
68
68
  }