Skip to content

Commit

Permalink
fix Store constructor is called when App is rerendered
Browse files Browse the repository at this point in the history
- make Store to be constructed only once
  • Loading branch information
wonpyo_kwon committed May 6, 2024
1 parent a44e6fb commit dccba04
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/renderer/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {MemoryRouter as Router, Routes, Route} from "react-router-dom";
import React, {useEffect, useRef} from "react";
import React, {useEffect, useRef, useState} from "react";
import useEvent from "react-use-event-hook";
import {ipcRenderer} from "electron";
import Control from "./prototypes/Control/Control";
Expand All @@ -10,7 +10,7 @@ import {SUPPORTED_MIME} from "./prototypes/constants/tracks";
import "./App.scss";
import useTracks from "./hooks/useTracks";
import useSelectedTracks from "./hooks/useSelectedTracks";
import {DevicePixelRatioProvider, StoreProvider} from "./contexts";
import {StoreProvider} from "./contexts";
import Store from "./Store";

function MyApp() {
Expand Down Expand Up @@ -136,6 +136,8 @@ function MyApp() {
prevTrackIds.current = trackIds;
}, [trackIds, selectTrackAfterAddTracks, selectTrackAfterRemoveTracks]);

const [store] = useState(new Store());

return (
<div id="App" className="App">
<PlayerControl />
Expand All @@ -152,7 +154,7 @@ function MyApp() {
commonNormalize={commonNormalize}
setCommonNormalize={setCommonNormalize}
/>
<StoreProvider value={new Store()}>
<StoreProvider value={store}>
<MainViewer
trackIds={trackIds}
erroredTrackIds={erroredTrackIds}
Expand Down

0 comments on commit dccba04

Please sign in to comment.