question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't call setState (or forceUpdate) on an unmounted component.

See original GitHub issue

Error:

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).

screen shot 2018-08-31 at 7 40 47 pm

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:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:5

github_iconTop GitHub Comments

4reactions
alexpopa-workcommented, Nov 26, 2018

I have the same problem and setting debounce to 0 didn’t help. The warning is still there half of the times.

4reactions
NayanPiouscommented, Nov 8, 2018

set debounce to 0 if it is fine with your usecase.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't call setState (or forceUpdate) on an unmounted ...
Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application....
Read more >
Prevent React setState on unmounted Component
Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application....
Read more >
Prevent React setState on unmounted component - Martin Belev
Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application...
Read more >
Fixing React's “Called SetState() on an ... - How-To Geek
Seeing called setState() on an unmounted component in your browser console means the callback for an async operation is still running after a ......
Read more >
Can't call setState (or forceUpdate) on an unmounted ... - GitHub
Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found