Recalculate on window resize and <details> toggle#17
Conversation
mruwnik
left a comment
There was a problem hiding this comment.
Am I correct in thinking that this sets the state just to trigger the rerender?
| // recalculate height on <details> toggle and window resize by forcing rerender | ||
| const [_, setStateToRerender] = useState() | ||
| useEffect(() => { | ||
| let isMounted = true |
There was a problem hiding this comment.
is this in case the eventlistners don't get destroyed properly? Or more to handle possible race conditions?
There was a problem hiding this comment.
yeah, the useless memory leak warning that was removed in React 18 facebook/react#22114 ... but the library supports React 17 too, so let's not scare ourselves when using this library in Stampy 😅
There was a problem hiding this comment.
and you are correct, it sets state to rerender .. moving code from https://github.com/StampyAI/stampy-ui/blob/3e3ae3ec4e7f4f1ad5a3ef70c3daf424eab92a3e/app/hooks/useRerenderOnResize.ts - but it needs to be new object every time to work, the set(empty) was a bug, so let's fix that here in the library and not in distant user code
No description provided.