oedotme / generouted

Generated file-based routes for Vite
https://stackblitz.com/github.com/oedotme/generouted/tree/main/explorer
MIT License
1.02k stars 47 forks source link

fix: wrap react hooks with useMemo; useCallback #147

Closed VriskaSerket51 closed 6 months ago

VriskaSerket51 commented 6 months ago

Currently, useNavigate and useModals create new instance every renders. This will cause infinite loop when someone uses hooks like:

const navigate = useNavigate();
useEffect(() => {
    // do something when path change or anything
}, [navigate]);

By wrapping hooks with React.useMemo and React.useCallback, they will not create new one each render.

oedotme commented 6 months ago

@VriskaSerket51 Thanks for those updates!

oedotme commented 6 months ago

Released at v1.18.4