-
Notifications
You must be signed in to change notification settings - Fork 6
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
Hook triggers unnecessary renderings (fix provided) #6
Comments
Awesome, thanks for sharing this. I really like the idea of storing the I think it makes sense to stick with Are there any problems with your app caused by focus triggered re-renders? If you don't want your app component to re-render one suggestion would be to put the call to Something like App = () => {
return (
<div>
{/* My app here */}
<DeployNotifications />
</div>
);
}
let DeployNotifications = () => {
let { hasNewDeploy } = useHasNewDeploy();
// .. whatever UI for you need for displaying notifications
} Again thanks for sharing this and I'll update this library to use a ref for last fetched. |
I'm glad that you like my code and thanks for the feedback. But I disagree with your opinion about using external libraries for extremely simple event handlers, explicitly if the library is triggering unexpected behaviors. It's always better to have no dependencies at all, also if you think about security. The re-renders triggered that some form elements became empty for some reason or prefilled with the browser autocomplete again. The tip with the wrapping component is a good idea and might work as a hacky workaround but it's still a misbehavior in the library. You can't expect that all users are noticing it and implement the hook in it that way. 😉 |
Every time the interval is executed or the window gets focused or blurred the entire app re-renders. I fixed the hook but don't have any time to create a PR. If you find any issues in my code, please leave a comment. With my code you can also remove 2 dependencies.
Feel free to use it:
The text was updated successfully, but these errors were encountered: