-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change the format of d3 effect hooks in the plot
I'm not 100% sure I'm doing this right, but here is what I did, and here is why I did it. 1) I started passing refs to DOM elements to the hooks rather than `hook.current`, and I took took that ref out of the dependency list for the hooks. The latter is easy: `ref.current` *never* changes because it always refers to the same object, so it doesn't make sense to have it as an effect dependency. <facebook/react#14387 (comment)> `useEffect` runs *after* the <svg> node has already been added to the DOM, so now we don't have to check if it is `null`. 2) I'm using `useLayoutEffect` rather than `useEffect`, because all of these hooks affect the state of the DOM-- they are just being managed by D3 rather than React.
- Loading branch information
Showing
1 changed file
with
61 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters