I am using Electron Store in Electron Js Project. The app is successfully built. But the electron store is not working in production/build version as I am not able to store the data persistently. What could be the reason for this?
ipcMain.handle("get-store-value", async (event, key) => {
return store.get(key);
});
ipcMain.handle("set-store-value", async (event, key, value) => {
store.set(key, value);
});
ipcMain.handle("delete-store-value", async (event, key) => {
store.delete(key);
});
useEffect(() => {
const fetchData = async () => {
try {
const nodesData = await ipcRenderer.invoke(
"get-store-value",
"nodes",
);
const edgesData = await ipcRenderer.invoke(
"get-store-value",
"edges",
);
// console.log("Fetched nodes:", nodesData);
// console.log("Fetched edges:", edgesData);
setNodes(JSON.parse(nodesData));
setEdges(JSON.parse(edgesData));
} catch (error) {
console.error("Error fetching data:", error);
setNodes([]);
setEdges([]);
}
};
fetchData();
}, []);
I am using this code in main js file and using ipcRenderer
to invoke this function in jsx file.