Skip to content

Commit

Permalink
Remove async useEffect functions
Browse files Browse the repository at this point in the history
  • Loading branch information
samirelanduk committed Mar 3, 2022
1 parent 5a3a3f9 commit 647b915
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions src/Molstar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,35 @@ const Molstar = props => {
const canvasRef = useRef(null);
const plugin = useRef(null);

useEffect(async () => {
if (useInterface) {
const spec = DefaultPluginUISpec();
spec.layout = {
initial: {
isExpanded: false,
controlsDisplay: "reactive",
showControls,
}
};
plugin.current = await createPluginAsync(parentRef.current, spec);
} else {
plugin.current = new PluginContext(DefaultPluginSpec());
plugin.current.initViewer(canvasRef.current, parentRef.current);
await plugin.current.init();
}
if (!showAxes) {
plugin.current.canvas3d?.setProps({ camera: { helper: { axes: {
name: "off", params: {}
} } } });
}
await loadStructure(pdbId, url, file, plugin.current);
useEffect(() => {
(async () => {
if (useInterface) {
const spec = DefaultPluginUISpec();
spec.layout = {
initial: {
isExpanded: false,
controlsDisplay: "reactive",
showControls,
}
};
plugin.current = await createPluginAsync(parentRef.current, spec);
} else {
plugin.current = new PluginContext(DefaultPluginSpec());
plugin.current.initViewer(canvasRef.current, parentRef.current);
await plugin.current.init();
}
if (!showAxes) {
plugin.current.canvas3d?.setProps({ camera: { helper: { axes: {
name: "off", params: {}
} } } });
}
await loadStructure(pdbId, url, file, plugin.current);
})();
return () => plugin.current = null;
}, [])

useEffect(async () => {
await loadStructure(pdbId, url, file, plugin.current);
useEffect(() => {
loadStructure(pdbId, url, file, plugin.current);
}, [pdbId, url, file])

useEffect(() => {
Expand Down

0 comments on commit 647b915

Please sign in to comment.