Repository navigation
Conversation
…en VisibilityProxy can't observe (LAZ-1698)
…placed element (LAZ-1698)
…l React 19 (LAZ-1698)
r1chm8
left a comment
There was a problem hiding this comment.
Thanks for working through all of these. I'm treating this as the last round: the two comments below are the only blockers, and I'll approve once they're in without doing another full review. Anything else I spot from here goes into a follow-up ticket rather than this PR.
| if (sWarnedComponentClasses.has(componentClass)) { | ||
| return; | ||
| } | ||
| sWarnedComponentClasses.add(componentClass); |
There was a problem hiding this comment.
This throws if an extension passes componentClass={React.Fragment} (or Suspense, StrictMode, Profiler). Those types are symbols, so they get past the typeof !== "string" check, and WeakSet.add(symbol) throws TypeError: Invalid value used in weak set. They don't take a ref, so they go down the findDOMNode path, and findDOMNode finds the first element of the content, so this line runs on mount and the tree unmounts. Master renders this fine, and Fragment is a likely thing to try, because the no-componentClass warning tells authors to pass one.
Could we only put functions and objects in the WeakSet (typeof componentClass === "function" || typeof componentClass === "object") and keep a plain Set for everything else? A test with componentClass={React.Fragment} would cover it.
| // observed node. A report on the detached node says nothing about the content. | ||
| if (!this.#inView && node.isConnected) { | ||
| if (!this.#inView) { | ||
| this.applyVisible(false); |
There was a problem hiding this comment.
With the node.isConnected guard gone, rows on the findDOMNode path can go blank for good. setElement handles a replaced element on the ref path, but the findDOMNode path only looks for the element again in componentDidUpdate. If a componentClass replaces its root element without the proxy re-rendering (e.g. connect(mapState)(Row) where Row swaps between differently keyed <tr>s on a store change, or Fast Refresh of a plain function), the proxy keeps watching the detached node. The observer reports it out of view, it hides after 1s, and a detached node never comes back into view.
Could we bring back a connected check before hiding, here and in the remaining < 0 branch above? For example, if this.#observed is no longer isConnected, call observeElement() again instead of hiding.
https://linear.app/nexus-mods/issue/LAZ-1698/clear-the-react-deprecation-warnings-out-of-the-renderer-tests
Summary
Our own components no longer call
findDOMNode, which React 19 removes. They use refs instead, and tests now fail if our code calls it again. Nothing changes for users.componentClassit now wraps its content in a<div>.componentClassthat does.findDOMNodenow fails, naming the caller. react-bootstrap's own calls don't count.Evidence
findDOMNodein 4 places the tests run (VisibilityProxy,Table,IconBar,ContextMenu). React only warned about 2 of them, because it warns once per test file and react-bootstrap's calls hid the rest.After: none. All renderer tests pass. A test where our code calls
findDOMNodefails; one where react-bootstrap calls it doesn't.Extension authors:
VisibilityProxynow finds its element through a ref. AcomponentClassthat doesn't pass its ref on to a DOM element (a react-bootstrap 0.33 component, or a function component withoutforwardRef) gets its content wrapped in a<div>inside it, so content still loads as it scrolls into view. Vortex logs a warning naming the class, once. Without acomponentClassthe content is wrapped in a<div>and Vortex warns once, so don't use it that way inside a<tbody>, a list, a flex or a grid: pass the element ascomponentClass.Other
findDOMNodecalls in our code (Dropdown,ActionDropdown,OverlayTrigger,DraggableListand others) aren't run by any test and are left for later; the check fails a test as soon as one is.Merge Danger
Door: two-way. Reverting brings back the old calls.
Blast Radius: tables and menus. Rows filling as you scroll, arrow keys in tables, and where icon-bar and right-click submenus open. An extension using
VisibilityProxywithout acomponentClassgets one extra<div>around its content.