Skip to content

Commit d81f862

Browse files
committed
fix for #165 #186 #145
1 parent 33247af commit d81f862

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1724,7 +1724,13 @@ function useSubscribedStateMethods<S>(
17241724
state.edition,
17251725
update,
17261726
);
1727-
React.useEffect(() => {
1727+
// useLayoutEffect here instead of useEffect because of this issue:
1728+
// https://github.com/avkonst/hookstate/issues/165#issuecomment-824670930
1729+
// and very likely this issue:
1730+
// https://github.com/avkonst/hookstate/issues/186
1731+
// and probably this issue:
1732+
// https://github.com/avkonst/hookstate/issues/145
1733+
React.useLayoutEffect(() => {
17281734
subscribeTarget.subscribe(link);
17291735
return () => {
17301736
link.onUnmount()

0 commit comments

Comments
 (0)