mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-15 10:09:45 +00:00
In development, persist application state across hot reloads.
This commit is contained in:
4
global.d.ts
vendored
4
global.d.ts
vendored
@@ -4,6 +4,10 @@ declare interface NodeModule {
|
|||||||
hot: any;
|
hot: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare interface Window {
|
||||||
|
STATE: any
|
||||||
|
}
|
||||||
|
|
||||||
declare namespace JSX {
|
declare namespace JSX {
|
||||||
interface Element { }
|
interface Element { }
|
||||||
interface IntrinsicElements { }
|
interface IntrinsicElements { }
|
||||||
|
|||||||
@@ -36,6 +36,17 @@ export default class App extends Component<Props, State> {
|
|||||||
|
|
||||||
enableDrawer = false;
|
enableDrawer = false;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
// In development, persist application state across hot reloads:
|
||||||
|
if (process.env.NODE_ENV === 'development') {
|
||||||
|
this.setState(window.STATE);
|
||||||
|
this.componentDidUpdate = () => {
|
||||||
|
window.STATE = this.state;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@bind
|
@bind
|
||||||
openDrawer() {
|
openDrawer() {
|
||||||
this.setState({ showDrawer: true });
|
this.setState({ showDrawer: true });
|
||||||
|
|||||||
Reference in New Issue
Block a user