Skip to content

Commit

Permalink
Remove forced re-render; it doesn't seem necessary any more. Part of #…
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Dec 12, 2024
1 parent 074c0e0 commit f6c092f
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/components/CollectionDialog.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext, useState, useReducer } from 'react';
import { useContext, useState } from 'react';
import PropTypes from 'prop-types';
import {
Button,
Expand Down Expand Up @@ -79,7 +79,6 @@ export function CollectionDialog({
}) {
const container = useContext(WorkspaceContext);
const [filter, setFilter] = useState(null);
const [, forceUpdate] = useReducer(x => x + 1, 0);

/** */
const hideDialog = () => {
Expand Down Expand Up @@ -115,18 +114,14 @@ export function CollectionDialog({
};

/** */
const dialogContainer = () => (container?.current || document.body).querySelector(`#${windowId}`);
const dialogContainer = (container?.current || document.body).querySelector(`#${windowId}`);

if (error) return null;
// If this component is optimistically rendering ahead of the window its in
// force a re-render so that it is placed correctly. The right thing here is
// to maybe pass a ref.
if (!dialogContainer()) {
forceUpdate();
if (!dialogContainer) {
return null;
}

if (!ready) return <Placeholder container={dialogContainer()} onClose={hideDialog} />;
if (!ready) return <Placeholder container={dialogContainer} onClose={hideDialog} />;

const rights = manifest && (asArray(manifest.getProperty('rights') || manifest.getProperty('license')));

Expand All @@ -144,7 +139,7 @@ export function CollectionDialog({
<Dialog
variant="contained"
onClose={hideDialog}
container={dialogContainer()}
container={dialogContainer}
open
>
<DialogTitle id="select-collection">
Expand Down

0 comments on commit f6c092f

Please sign in to comment.