Skip to content

Commit

Permalink
Swap react to use createRoot in v18 style, formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
dannon committed Aug 3, 2023
1 parent 49d67b3 commit 86caa8e
Showing 1 changed file with 16 additions and 27 deletions.
43 changes: 16 additions & 27 deletions config/plugins/visualizations/h5web/src/script.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,35 @@
/**
* Visualizer interface for h5web (https://github.com/silx-kit/h5web)
*
*
* This relies on Galaxy being able to serve files using the
* h5grove protocol (https://silx-kit.github.io/h5grove/).
* h5grove protocol (https://silx-kit.github.io/h5grove/).
* This provides efficient access to the contents of the
* HDF5 file and avoids having to read the whole file at any
* point.
*/

import './styles.css';
import React from 'react'
import {render as reactRender} from 'react-dom'
import {App, H5GroveProvider} from '@h5web/app'
import "./styles.css";
import React from "react";
import { createRoot } from "react-dom/client";
import { App, H5GroveProvider } from "@h5web/app";

function MyApp(props) {
return (
<H5GroveProvider
url={props.url}
filepath={props.name}
axiosConfig={{ params: { file: props.name } }}
>
<H5GroveProvider url={props.url} filepath={props.name} axiosConfig={{ params: { file: props.name } }}>
<App explorerOpen={props.explorer} />
</H5GroveProvider>
);
</H5GroveProvider>
);
}

window.bundleEntries = window.bundleEntries || {};
window.bundleEntries.load = function (options) {
var dataset = options.dataset;
var settings = options.chart.settings;
var explorer = settings.get('explorer');
var url = window.location.origin + "/api/datasets/" + dataset.id + "/content";
reactRender(
<MyApp
url={url}
name={dataset.name}
filepath={dataset.file_name}
explorer={explorer}
/>,
document.getElementById(options.target)
)
options.chart.state('ok', 'Chart drawn.');
const dataset = options.dataset;
const settings = options.chart.settings;
const explorer = settings.get("explorer");
const url = window.location.origin + "/api/datasets/" + dataset.id + "/content";
const root = createRoot(document.getElementById(options.target));
root.render(<MyApp url={url} name={dataset.name} filepath={dataset.file_name} explorer={explorer} />);
options.chart.state("ok", "Chart drawn.");
options.process.resolve();
};

Expand Down

0 comments on commit 86caa8e

Please sign in to comment.