Skip to content

Commit 514d18a

Browse files
Merge pull request #4035 from ProjectMirador/4016
Remove forced re-render; it doesn't seem necessary any more.
2 parents 074c0e0 + f6c092f commit 514d18a

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/components/CollectionDialog.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useContext, useState, useReducer } from 'react';
1+
import { useContext, useState } from 'react';
22
import PropTypes from 'prop-types';
33
import {
44
Button,
@@ -79,7 +79,6 @@ export function CollectionDialog({
7979
}) {
8080
const container = useContext(WorkspaceContext);
8181
const [filter, setFilter] = useState(null);
82-
const [, forceUpdate] = useReducer(x => x + 1, 0);
8382

8483
/** */
8584
const hideDialog = () => {
@@ -115,18 +114,14 @@ export function CollectionDialog({
115114
};
116115

117116
/** */
118-
const dialogContainer = () => (container?.current || document.body).querySelector(`#${windowId}`);
117+
const dialogContainer = (container?.current || document.body).querySelector(`#${windowId}`);
119118

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

129-
if (!ready) return <Placeholder container={dialogContainer()} onClose={hideDialog} />;
124+
if (!ready) return <Placeholder container={dialogContainer} onClose={hideDialog} />;
130125

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

@@ -144,7 +139,7 @@ export function CollectionDialog({
144139
<Dialog
145140
variant="contained"
146141
onClose={hideDialog}
147-
container={dialogContainer()}
142+
container={dialogContainer}
148143
open
149144
>
150145
<DialogTitle id="select-collection">

0 commit comments

Comments
 (0)