slate-react 0.72.8 → 0.72.9-202215114220

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
@@ -1,5 +1,11 @@
1
1
  # slate-react
2
2
 
3
+ ## 0.72.9-202215114220
4
+
5
+ ### Patch Changes
6
+
7
+ - [#4819](https://github.com/ianstormtaylor/slate/pull/4819) [`80661509`](https://github.com/ianstormtaylor/slate/commit/80661509ecf39b5d8256fa387c7eff15f60bf612) Thanks [@ugaya40](https://github.com/ugaya40)! - Fix a possible update of react state after Slate component is unmounted
8
+
3
9
  ## 0.72.8
4
10
 
5
11
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"slate.d.ts","sourceRoot":"","sources":["../packages/slate-react/src/components/slate.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAA;AACxE,OAAO,EAAyB,UAAU,EAAE,MAAM,OAAO,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAOpD;;;GAGG;AAEH,eAAO,MAAM,KAAK;YACR,WAAW;WACZ,UAAU,EAAE;cACT,KAAK,CAAC,SAAS;sBACP,UAAU,EAAE,KAAK,IAAI;iBA+DxC,CAAA"}
1
+ {"version":3,"file":"slate.d.ts","sourceRoot":"","sources":["../packages/slate-react/src/components/slate.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAA;AAChF,OAAO,EAAyB,UAAU,EAAE,MAAM,OAAO,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAOpD;;;GAGG;AAEH,eAAO,MAAM,KAAK;YACR,WAAW;WACZ,UAAU,EAAE;cACT,KAAK,CAAC,SAAS;sBACP,UAAU,EAAE,KAAK,IAAI;iBAoExC,CAAA"}
package/dist/index.es.js CHANGED
@@ -3897,6 +3897,7 @@ var Slate = props => {
3897
3897
  } = props,
3898
3898
  rest = _objectWithoutProperties(props, _excluded);
3899
3899
 
3900
+ var unmountRef = useRef(false);
3900
3901
  var [context, setContext] = React.useState(() => {
3901
3902
  if (!Node.isNodeList(value)) {
3902
3903
  throw new Error("[Slate] value is invalid! Expected a list of elements" + "but got: ".concat(JSON.stringify(value)));
@@ -3918,6 +3919,7 @@ var Slate = props => {
3918
3919
  useEffect(() => {
3919
3920
  return () => {
3920
3921
  EDITOR_TO_ON_CHANGE.set(editor, () => {});
3922
+ unmountRef.current = true;
3921
3923
  };
3922
3924
  }, []);
3923
3925
  var [isFocused, setIsFocused] = useState(ReactEditor.isFocused(editor));
@@ -3927,6 +3929,10 @@ var Slate = props => {
3927
3929
  useIsomorphicLayoutEffect(() => {
3928
3930
  var fn = () => {
3929
3931
  setTimeout(() => {
3932
+ if (unmountRef.current) {
3933
+ return;
3934
+ }
3935
+
3930
3936
  setIsFocused(ReactEditor.isFocused(editor));
3931
3937
  }, 0);
3932
3938
  };