Can't call setState (or forceUpdate) on an unmounted component.
See original GitHub issueError:
Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
Description:
Pressing on a “Place” item in the listview from react-native-google-places-autocomplete
triggers the error. I’ve stepped through it in Chrome’s devtools and found the error occurs right after TouchableHighlight
from _renderRow
(please see screenshot below).
Code:
<GooglePlacesAutocomplete
autoFocus
debounce={200}
enablePoweredByContainer={false}
fetchDetails={false}
GooglePlacesSearchQuery={{
rankby: 'distance',
types: 'establishment'
}}
listViewDisplayed={destinationInput}
minLength={2}
nearByPlacesAPI="GooglePlacesSearch"
onPress={data => setDestination(data)}
placeholder="Where to?"
placeholderTextColor="black"
ref={setRef}
returnKeyType="search"
styles={searchDestStyle}
textInputProps={{
onBlur: blurDest,
onFocus: focusDest
}}
query={{
key: config.apiKey,
language: 'en',
types: ['establishment', 'geocode'],
location: '37.786279,-122.406456',
radius: '15000',
components: 'country:us'
}}
/>
destinationInput
is a Boolean from redux state.
setDestination, blurDest, focusDest
are a redux action creators.
setDestination
sends the location data to redux state, which react-native-maps-directions
uses to send direction coordinates to react-native-maps
. Then a react-native
modal is triggered.
Relevant dependencies:
"expo": "^29.0.0",
"react": "16.4.2",
"react-native": "https://github.com/expo/react-native/archive/sdk-29.0.0.tar.gz",
"react-native-google-places-autocomplete": "^1.3.9"
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:5
Top GitHub Comments
I have the same problem and setting debounce to 0 didn’t help. The warning is still there half of the times.
set debounce to 0 if it is fine with your usecase.