@reactables/react 1.1.0-beta.0 → 1.1.0

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.
Files changed (2) hide show
  1. package/dist/index.js +9 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -25,8 +25,15 @@ var useReactable = function (reactableFactory) {
25
25
  var subscription = state$.subscribe(function (result) {
26
26
  setState(result);
27
27
  });
28
- var unsubscribe = subscription.unsubscribe.bind(subscription);
29
- return unsubscribe;
28
+ return function () {
29
+ // Adding setTimeout fixes the issue.
30
+ // React Strict Mode has bugs with clean up with refs so it breaks the useReactable hook as of now
31
+ // See Bug: https://github.com/facebook/react/issues/26315
32
+ // See Bug: https://github.com/facebook/react/issues/24670
33
+ setTimeout(function () {
34
+ subscription.unsubscribe();
35
+ }, 0);
36
+ };
30
37
  }, [state$]);
31
38
  return [state, actions, state$, messages$];
32
39
  };
package/package.json CHANGED
@@ -17,5 +17,5 @@
17
17
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
18
18
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
19
19
  },
20
- "version": "1.1.0-beta.0"
20
+ "version": "1.1.0"
21
21
  }