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
Following your guide, I added zutron to the window type
declare global {interfaceWindow{themeMode: ThemeModeContext;electronWindow: ElectronWindow;zutron: Handlers<AppState>;}}
and the context bridge to the preload.ts:
importexposeContextsfrom"./helpers/ipc/context-exposer";import{contextBridge}from'electron';import{preloadZustandBridge}from'zutron/preload';import{AppState}from"./main";exposeContexts();// instantiate bridgeexportconst{ handlers }=preloadZustandBridge<AppState>();// expose handlers to renderer processcontextBridge.exposeInMainWorld('zutron',handlers);
After trying to find a solution, I found some references that the error might happen because there are states that can't be serialized and thus not synced over IPC, but there are no such states...
Any idea what I'm doing wrong?
The text was updated successfully, but these errors were encountered:
@LeoLTM It's difficult to see what's going on here without a minimal reproduction. The code you posted here looks fine, and as you say, the error is what you'd expect from trying to send something too complex over IPC. I just released 0.8 with improved docs, maybe this helps.
Some things to check:
The store passed to Zutron needs to be created using the zustand/vanilla function
Try commenting out slices one by one to see what might be causing the issues.
Try digging into the Zutron source (it's not that big) and log out the messages before they across the bridge to get an idea of where it might be breaking
I tried to move from a regular
zustand
setup with multiple "slices" tozutron
, but I as soon as I pass the store to the renderer withI get the error
and my states in the frontend are
undefined
.This is how I create my store:
I added the
& { [key: string]: any; }
because myAppState
type was not compatible withAnyState
that is required bymainZustandBridge()
.This is how a slice looks like:
This is how I call the store in the React components:
Following your guide, I added
zutron
to thewindow
typeand the context bridge to the
preload.ts
:After trying to find a solution, I found some references that the error might happen because there are states that can't be serialized and thus not synced over IPC, but there are no such states...
Any idea what I'm doing wrong?
The text was updated successfully, but these errors were encountered: