Skip to content

Commit

Permalink
pref: render optimizations (#98)
Browse files Browse the repository at this point in the history
panel and schedule visualizer components are memoized to avoid rendering when nothing changed.

This improves rendering times by around 100-150% based the mock scenario.
  • Loading branch information
Teo Koon Peng authored Sep 4, 2020
1 parent 9484c6d commit bd7e3b7
Show file tree
Hide file tree
Showing 49 changed files with 1,306 additions and 952 deletions.
76 changes: 53 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"clsx": "^1.1.0",
"debug": "^4.1.1",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"enzyme-adapter-react-16": "^1.15.4",
"eventemitter3": "^4.0.0",
"leaflet": "^1.6.0",
"react": "^16.12.0",
Expand Down
5 changes: 0 additions & 5 deletions src/app-contexts.ts

This file was deleted.

25 changes: 25 additions & 0 deletions src/components/app-contexts.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
import { ResourceConfigurationsType } from '../resource-manager';
import { defaultSettings, Settings } from '../settings';
import { NotificationBarContext, NotificationBarProps } from './notification-bar';

/* Declares the ResourcesContext which contains the resources used on the app*/
export const ResourcesContext = React.createContext<ResourceConfigurationsType>({});

export const SettingsContext = React.createContext(defaultSettings());

export interface AppContextProviderProps extends React.PropsWithChildren<{}> {
settings: Settings;
notificationDispatch: React.Dispatch<React.SetStateAction<NotificationBarProps | null>>;
}

export function AppContextProvider(props: AppContextProviderProps): React.ReactElement {
const { settings, notificationDispatch, children } = props;
return (
<SettingsContext.Provider value={settings}>
<NotificationBarContext.Provider value={notificationDispatch}>
{children}
</NotificationBarContext.Provider>
</SettingsContext.Provider>
);
}
Loading

0 comments on commit bd7e3b7

Please sign in to comment.