Hello @christianalfoni
There is a bug that happens in specific conditions, component does not connect to overmind and does not react on state changes.
Background and problem
I updated overmind packages to the latest versions:
"overmind": "28.0.1",
"overmind-react": "29.0.1",
Migrated codebase according to the migration guide.
While testing I noticed that <Header /> component does not render icons after logging-in:

Icons:

In the devtools I see that <Header /> isn't connected even though I have useOvermindState and some state used inside render function:

The only functionality-relevant change is removing onInitialize and creating new action called onInitializeOvermind. After some digging I discovered conditions in which bug appear:
- Setting boolean flag to
false inside onInitializeOvermind
- Accessing boolean flag in component via
useOvermindState hook.
const Component1 = () => {
const { someBooleanValue } = useOvermindState();
return (<div>{String(someBooleanValue)}</div>)
}
- Running action that updates boolean to
true inside function component's body, e.g
const Component2 = () => {
const { setToTrue } = useOvermindActions();
setToTrue();
return (<div>Some text</div>)
}
In such case Component1 won't connect to overmind and will ignore any changes to someBooleanValue.
Reproducible examples
CodeSandbox number one has an old version of overmind with onInitialize where everything is working as expected (Press Toggle to see changes): https://codesandbox.io/s/overmind-connect-issue-old-working-0jm9w?file=/src/FinishLoginOnMount.tsx
Codesandbox is the same code migrated according to the guide. Component does not connect to overmind (Toggle changes value in state but component doesn't care): https://codesandbox.io/s/overmind-connect-issue-60u5w
Expected behavior
I would expect the same behavior as in older version of overmind 27.0.0. Component should connect anyway, doesn't matter how I call actions (inside useEffect or in function component's body) and whether I change flag inside initializeOvermind.
I hope it helps. @christianalfoni Will you have a chance to look at it?
Hello @christianalfoni
There is a bug that happens in specific conditions, component does not connect to overmind and does not react on state changes.
Background and problem
I updated overmind packages to the latest versions:
Migrated codebase according to the migration guide.

While testing I noticed that
<Header />component does not render icons after logging-in:Icons:

In the devtools I see that

<Header />isn't connected even though I haveuseOvermindStateand some state used inside render function:The only functionality-relevant change is removing
onInitializeand creating new action calledonInitializeOvermind. After some digging I discovered conditions in which bug appear:falseinsideonInitializeOverminduseOvermindStatehook.trueinside function component's body, e.gIn such case
Component1won't connect to overmind and will ignore any changes tosomeBooleanValue.Reproducible examples
CodeSandbox number one has an old version of overmind with
onInitializewhere everything is working as expected (PressToggleto see changes): https://codesandbox.io/s/overmind-connect-issue-old-working-0jm9w?file=/src/FinishLoginOnMount.tsxCodesandbox is the same code migrated according to the guide. Component does not connect to overmind (
Togglechanges value in state but component doesn't care): https://codesandbox.io/s/overmind-connect-issue-60u5wExpected behavior
I would expect the same behavior as in older version of overmind
27.0.0. Component should connect anyway, doesn't matter how I call actions (inside useEffect or in function component's body) and whether I change flag inside initializeOvermind.I hope it helps. @christianalfoni Will you have a chance to look at it?