* Attempted Lazy load for OHIFCornerStoneViewport * Converted dicom-(html, microscopy, pdf) & cornerstone extensions to React Lazy components * Fixed incorrect import from OHIFDicomPDFSopClassHandler to ConnectedOHIFDicomPDFViewer Co-authored-by: Ankit Mohan <ankit.mohan@live.in> Co-authored-by: Erik Ziegler <erik.sweed@gmail.com>
This commit is contained in:
parent
d57158b59d
commit
0139a32213
@ -1,37 +0,0 @@
|
|||||||
/**
|
|
||||||
* We use this component to leverage "Code Splitting"
|
|
||||||
*
|
|
||||||
* Link: https://serverless-stack.com/chapters/code-splitting-in-create-react-app.html
|
|
||||||
*/
|
|
||||||
|
|
||||||
import React, { Component } from 'react';
|
|
||||||
|
|
||||||
export default function asyncComponent(importComponent) {
|
|
||||||
class AsyncComponent extends Component {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
|
|
||||||
this.state = {
|
|
||||||
component: null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async componentDidMount() {
|
|
||||||
// Add dynamically loaded component to state
|
|
||||||
const { default: component } = await importComponent();
|
|
||||||
|
|
||||||
this.setState({
|
|
||||||
component: component,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const C = this.state.component;
|
|
||||||
|
|
||||||
// Render the loaded component, or null
|
|
||||||
return C ? <C {...this.props} /> : null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return AsyncComponent;
|
|
||||||
}
|
|
||||||
@ -1,14 +1,20 @@
|
|||||||
|
import React from 'react';
|
||||||
import init from './init.js';
|
import init from './init.js';
|
||||||
import asyncComponent from './asyncComponent.js';
|
|
||||||
import commandsModule from './commandsModule.js';
|
import commandsModule from './commandsModule.js';
|
||||||
import toolbarModule from './toolbarModule.js';
|
import toolbarModule from './toolbarModule.js';
|
||||||
import CornerstoneViewportDownloadForm from './CornerstoneViewportDownloadForm';
|
import CornerstoneViewportDownloadForm from './CornerstoneViewportDownloadForm';
|
||||||
|
|
||||||
const OHIFCornerstoneViewport = asyncComponent(() =>
|
const Component = React.lazy(() => {
|
||||||
import(
|
return import('./OHIFCornerstoneViewport');
|
||||||
/* webpackChunkName: "OHIFCornerstoneViewport" */ './OHIFCornerstoneViewport.js'
|
});
|
||||||
)
|
|
||||||
);
|
const OHIFCornerstoneViewport = props => {
|
||||||
|
return (
|
||||||
|
<React.Suspense fallback={<div>Loading...</div>}>
|
||||||
|
<Component {...props} />
|
||||||
|
</React.Suspense>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@ -1,37 +0,0 @@
|
|||||||
/**
|
|
||||||
* We use this component to leverage "Code Splitting"
|
|
||||||
*
|
|
||||||
* Link: https://serverless-stack.com/chapters/code-splitting-in-create-react-app.html
|
|
||||||
*/
|
|
||||||
|
|
||||||
import React, { Component } from 'react';
|
|
||||||
|
|
||||||
export default function asyncComponent(importComponent) {
|
|
||||||
class AsyncComponent extends Component {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
|
|
||||||
this.state = {
|
|
||||||
component: null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async componentDidMount() {
|
|
||||||
// Add dynamically loaded component to state
|
|
||||||
const { default: component } = await importComponent();
|
|
||||||
|
|
||||||
this.setState({
|
|
||||||
component: component,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const C = this.state.component;
|
|
||||||
|
|
||||||
// Render the loaded component, or null
|
|
||||||
return C ? <C {...this.props} /> : null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return AsyncComponent;
|
|
||||||
}
|
|
||||||
@ -1,11 +1,17 @@
|
|||||||
import asyncComponent from './asyncComponent.js';
|
import React from 'react';
|
||||||
import OHIFDicomHtmlSopClassHandler from './OHIFDicomHtmlSopClassHandler.js';
|
import OHIFDicomHtmlSopClassHandler from './OHIFDicomHtmlSopClassHandler.js';
|
||||||
|
|
||||||
const OHIFDicomHtmlViewport = asyncComponent(() =>
|
const Component = React.lazy(() => {
|
||||||
import(
|
return import('./OHIFDicomHtmlViewport');
|
||||||
/* webpackChunkName: "OHIFDicomHtmlViewport" */ './OHIFDicomHtmlViewport.js'
|
});
|
||||||
)
|
|
||||||
);
|
const OHIFDicomHtmlViewport = props => {
|
||||||
|
return (
|
||||||
|
<React.Suspense fallback={<div>Loading...</div>}>
|
||||||
|
<Component {...props} />
|
||||||
|
</React.Suspense>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,37 +0,0 @@
|
|||||||
/**
|
|
||||||
* We use this component to leverage "Code Splitting"
|
|
||||||
*
|
|
||||||
* Link: https://serverless-stack.com/chapters/code-splitting-in-create-react-app.html
|
|
||||||
*/
|
|
||||||
|
|
||||||
import React, { Component } from 'react';
|
|
||||||
|
|
||||||
export default function asyncComponent(importComponent) {
|
|
||||||
class AsyncComponent extends Component {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
|
|
||||||
this.state = {
|
|
||||||
component: null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async componentDidMount() {
|
|
||||||
// Add dynamically loaded component to state
|
|
||||||
const { default: component } = await importComponent();
|
|
||||||
|
|
||||||
this.setState({
|
|
||||||
component: component,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const C = this.state.component;
|
|
||||||
|
|
||||||
// Render the loaded component, or null
|
|
||||||
return C ? <C {...this.props} /> : null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return AsyncComponent;
|
|
||||||
}
|
|
||||||
@ -1,11 +1,17 @@
|
|||||||
import asyncComponent from './asyncComponent.js';
|
import React from 'react';
|
||||||
import DicomMicroscopySopClassHandler from './DicomMicroscopySopClassHandler.js';
|
import DicomMicroscopySopClassHandler from './DicomMicroscopySopClassHandler.js';
|
||||||
|
|
||||||
const DicomMicroscopyViewport = asyncComponent(() =>
|
const Component = React.lazy(() => {
|
||||||
import(
|
return import('./DicomMicroscopyViewport');
|
||||||
/* webpackChunkName: "DicomMicroscopyViewport" */ './DicomMicroscopyViewport.js'
|
});
|
||||||
)
|
|
||||||
);
|
const DicomMicroscopyViewport = props => {
|
||||||
|
return (
|
||||||
|
<React.Suspense fallback={<div>Loading...</div>}>
|
||||||
|
<Component {...props} />
|
||||||
|
</React.Suspense>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,37 +0,0 @@
|
|||||||
/**
|
|
||||||
* We use this component to leverage "Code Splitting"
|
|
||||||
*
|
|
||||||
* Link: https://serverless-stack.com/chapters/code-splitting-in-create-react-app.html
|
|
||||||
*/
|
|
||||||
|
|
||||||
import React, { Component } from 'react';
|
|
||||||
|
|
||||||
export default function asyncComponent(importComponent) {
|
|
||||||
class AsyncComponent extends Component {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
|
|
||||||
this.state = {
|
|
||||||
component: null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async componentDidMount() {
|
|
||||||
// Add dynamically loaded component to state
|
|
||||||
const { default: component } = await importComponent();
|
|
||||||
|
|
||||||
this.setState({
|
|
||||||
component: component,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const C = this.state.component;
|
|
||||||
|
|
||||||
// Render the loaded component, or null
|
|
||||||
return C ? <C {...this.props} /> : null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return AsyncComponent;
|
|
||||||
}
|
|
||||||
@ -1,11 +1,17 @@
|
|||||||
import asyncComponent from './asyncComponent.js';
|
import React from 'react';
|
||||||
import OHIFDicomPDFSopClassHandler from './OHIFDicomPDFSopClassHandler.js';
|
import OHIFDicomPDFSopClassHandler from './OHIFDicomPDFSopClassHandler.js';
|
||||||
|
|
||||||
const ConnectedOHIFDicomPDFViewer = asyncComponent(() =>
|
const Component = React.lazy(() => {
|
||||||
import(
|
return import('./ConnectedOHIFDicomPDFViewer');
|
||||||
/* webpackChunkName: "ConnectedOHIFDicomPDFViewer" */ './ConnectedOHIFDicomPDFViewer'
|
});
|
||||||
)
|
|
||||||
);
|
const ConnectedOHIFDicomPDFViewer = props => {
|
||||||
|
return (
|
||||||
|
<React.Suspense fallback={<div>Loading...</div>}>
|
||||||
|
<Component {...props} />
|
||||||
|
</React.Suspense>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user