Unnecessary re-renders triggered whenever click event gets fired
See original GitHub issueWhile i was investigating some performance issues within my projects I noticed that your component re-render on every click. So I used React profiler and it turns out the suggestions
state variable keep changing for each click (even outside of the component). I looked into the source and found this:
https://github.com/Tintef/react-google-places-autocomplete/blob/db8e6b4d7f2a4eac1dd7d85d6bb0914e8f68eb2c/src/GooglePlacesAutocomplete/index.js#L55
which apparently used to clear the suggestions when the component lose focus
https://github.com/Tintef/react-google-places-autocomplete/blob/db8e6b4d7f2a4eac1dd7d85d6bb0914e8f68eb2c/src/GooglePlacesAutocomplete/index.js#L90-L96
I think there is another ways to do it than adding event listener on the document level
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
@bahaa-kallas This is already merged in master (but still an alpha release), please let me know if this is still an issue on
v3.0.0-alpha.1
@bahaa-kallas FYI, this is already released as an alpha version, you can install it with:
yarn add react-google-places-autocomplete@3.0.0-alpha.1
And you can find the new docs here