fix(script-tag): Include React and ReactDOM as dependencies and add installViewer function to simplify script tag usage. (#721)

This commit is contained in:
Erik Ziegler authored and GitHub committed 2019-07-29 08:20:07 +02:00
1 parent 210c2e8d2c
commit 5802cf18eb
5 files changed
+67 -19

No files matched your search

+7 -1
View File
@@ -4,9 +4,15 @@ import cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader';
import dicomParser from 'dicom-parser';
import version from './version.js';
let homepage;
const { process } = window;
if (process && process.env && process.env.PUBLIC_URL) {
homepage = process.env.PUBLIC_URL;
}
window.info = {
version,
homepage: `${process.env.PUBLIC_URL}`,
homepage,
};
// For debugging
+15 -1
View File
@@ -2,5 +2,19 @@
* Entry point index.js for rollup packaging
*/
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App.js';
export { App };
function installViewer(props, containerId = "root", callback) {
const container = document.getElementById(containerId);
if (!container) {
throw new Error("No root element found to install viewer. Please add a <div> with the id 'root', or pass a DOM element into the installViewer function.");
}
return ReactDOM.render(<App {...props}/>, container, callback);
}
export { App, installViewer };