Skip to content

Conversation

@Aprillion
Copy link
Owner

No description provided.

Copy link

@mruwnik mruwnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this in case the eventlistners don't get destroyed properly? Or more to handle possible race conditions?

Copy link
Owner Author

@Aprillion Aprillion Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 😅

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@Aprillion Aprillion merged commit 08068e5 into master Jul 6, 2023
@Aprillion Aprillion deleted the resize-details branch July 8, 2023 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants