-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Rendering does not work on React 18 #275
Comments
in my e.g. LinearReadArcsDisplay I have code like this where i wrap the ref callback with a useCallback:
this has, in my experience, reduced the amount of times the ref gets destroyed and recreated. however, I am wondering if that is the true cause of the error. the maximum depth exceeded is often due to Creating an observable e.g. during rendering. In the react 18 PR, we had an example of this with the connection code (see https://github.com/GMOD/jbrowse-components/pull/3502/files#diff-faaefea17f30fdf77887b47ad504682c377319f693394238f7e615bcc48b6bd8R43) mobx discussion thread mobxjs/mobx#3728 (comment) also, not sure if related, but with this code:
instead of calling that during rendering, I would maybe move that to a useEffect? would be happy to pair on this if interested |
I tried return (
<canvas
ref={async (node: HTMLCanvasElement) => {
await Promise.resolve()
setCollaboratorCanvas(node)
}}
width={width}
height={height}
/>
) |
nice! I don't think there's anything wrong with that. I'd have to think about why this is happening in your case but that seems like a good workaround |
JBrowse recently updated to React 18, which has caused the display rendering to not work. We need to see if it's something we can fix on our side easily, and if not, then discuss with JBrowse team possibly reverting that update for now (see this comment).
Here is the text of the error:
I've tracked it down to LinearApolloDisplay where we have three calls like this:
Apollo3/packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/components/LinearApolloDisplay.tsx
Lines 89 to 91 in cb7d2ab
where
setCollaboratorCanvas
is an MST action that sets the canvas in a volatile node on the display's state tree. Even if the state tree doesn't do anything with the canvas node, just setting it is enough to cause this error, and all three instances of storing a ref in the MST model cause this error.The only other thing I've been able to figure out is that it likely has something to do with the usage of React 18's
useSyncExternalStore
inmobx-react
. React's DevTools tells me that the component keeps re-rendering because of hook 3 here:The text was updated successfully, but these errors were encountered: