2
0
Эх сурвалжийг харах

Update the state properly

Panayiotis Lipiridis 4 жил өмнө
parent
commit
922e28a198

+ 1 - 0
src/components/App.tsx

@@ -388,6 +388,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
         />
         />
         {this.state.showStats && (
         {this.state.showStats && (
           <Stats
           <Stats
+            setAppState={this.setAppState}
             appState={this.state}
             appState={this.state}
             elements={this.scene.getElements()}
             elements={this.scene.getElements()}
             onClose={this.toggleStats}
             onClose={this.toggleStats}

+ 4 - 2
src/components/Stats.tsx

@@ -24,6 +24,7 @@ const getStorageSizes = debounce((cb: (sizes: StorageSizes) => void) => {
 }, 500);
 }, 500);
 
 
 export const Stats = (props: {
 export const Stats = (props: {
+  setAppState: React.Component<any, AppState>["setState"];
   appState: AppState;
   appState: AppState;
   elements: readonly NonDeletedExcalidrawElement[];
   elements: readonly NonDeletedExcalidrawElement[];
   onClose: () => void;
   onClose: () => void;
@@ -47,8 +48,9 @@ export const Stats = (props: {
   const selectedBoundingBox = getCommonBounds(selectedElements);
   const selectedBoundingBox = getCommonBounds(selectedElements);
 
 
   const onGridSizeChange = () => {
   const onGridSizeChange = () => {
-    //TODO: Update the state properly and rerender the grid
-    props.appState.gridSize = ((props.appState.gridSize - 5) % 50) + 10;
+    props.setAppState({
+      gridSize: ((props.appState.gridSize - 5) % 50) + 10,
+    });
   };
   };
 
 
   if (isMobile && props.appState.openMenu) {
   if (isMobile && props.appState.openMenu) {