You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On the client you just want to make sure that your Overmind instance rehydrates the mutations performed on the server so that when the client renders, it does so with the same state. The **onInitialize** hook of Overmind is the perfect spot to do this.
82
82
83
83
{% tabs %}
84
-
{% tab title="overmind/onInitialize.ts" %}
84
+
{% tab title="overmind/actions.ts" %}
85
85
```typescript
86
-
import { OnInitialize, rehydrate } from'overmind'
86
+
import { rehydrate } from'overmind'
87
87
88
-
exportconstonInitialize:OnInitialize= ({ state }) => {
If you are using state first routing, make sure you prevent the router from firing off the initial route, as this is not needed.
99
99
{% endhint %}
100
100
101
-
## OnInitialize
101
+
## OnInitializeOvermind
102
102
103
103
The `onInitializeOvermind` action does not run on the server. The reason is that it is considered a side effect you might not want to run, so we do not force it. If you do want to run an action as Overmind fires up both on the client and the server you can rather call it manually:
104
104
@@ -213,7 +213,7 @@ import { createHook } from "overmind-react";
213
213
exportconstconfig= {
214
214
state: {},
215
215
actions: {
216
-
add
216
+
add: {
217
217
changePage({ state }, mutations) {
218
218
rehydrate(state, mutations || []);
219
219
}
@@ -228,7 +228,7 @@ And you are all set to get going with `overmind` and `next.js`. You can also tak
228
228
229
229
## Gatsby
230
230
231
-
When it comes to gatsby we need to prepare Overmind for static extraction and the idea is about the same.
231
+
When it comes to Gatsby we need to prepare Overmind for static extraction and the idea is about the same.
232
232
233
233
We need first to wrap our whole app in the Overmind provider and we can do that in `gatsby-browser.js`:
0 commit comments