react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Excessive number of pending callbacks: 501.

Open nguptaesaral opened this issue 2 years ago • 12 comments

Description

Hi There, I am using TouchableOpacity inside the FlatLis. And the FlatList data has 500 objects. when the data appearing on the screen, it is showing a warning as below Screenshot

function for gating data const CallLogsAPI = async (employee_id) => { try { // setIsLoading(true) let res = await axios.post(${BASE_URL}/Temp/getCallLogs, { employee_id }, { timeout: 3000 }) let data = res.data.data // console.log('apiLogData', data) SetApiLogData(data) setIsLoading(false) }

    catch (e) { console.log("bb", e) }
    setIsLoading(false)
} 

return data to screen:

return ( <View style={{ height: '100%' }}> {/* { isLoading && <View style={styles.loading}> <ActivityIndicator size={50} color="dimgray" animating={isLoading} /> </View> } <View style={styles.sync}> <Icon name='sync-circle' size={70} color='#2196F3' onPress={() => { setIsLoading(true); GetDeviceLogs(employee_id) }} /> </View> */}

        <FlatList
            data={apiLogData}
            initialNumToRender='15'
            refreshControl={
                <RefreshControl
                  refreshing={isLoading}
                  onRefresh={()=>{setIsLoading(true); GetDeviceLogs(employee_id)}}
                  colors={['red','blue',"yellow"]}
                />}
            renderItem={({ item }) => {

                return (
                    <View style={[styles.card, styles.elevation]}>

                        <View style={{ flex: 2, flexDirection: "row", justifyContent: "space-between" }}>
                            <View >
                                <TouchableOpacity onPress={() => navigation.navigate("rename", { 'contactId': item.contactId })}>
                                    <Text style={styles.heading}>{item.name ? item.name : 'Unknown'}</Text>
                                </TouchableOpacity>
                            </View >
                            <View style={{ flexDirection: "row", justifyContent: "center", paddingRight:5 }}>

                                <TouchableOpacity onPress={() => ExtLinks(`tel:${item.phoneNumber}`)}>
                                    <Text style={{ marginHorizontal: 8 }}><SvgIcons.Call /></Text>
                                </TouchableOpacity>

                                {/* <TouchableOpacity onPress={() => ExtLinks(`sms:${item.phoneNumber}`)}>
                                    <Text style={{ margin: 5 }}><SvgIcons.Message /></Text>
                                </TouchableOpacity> */}

                                <TouchableOpacity onPress={() => ExtLinks(`whatsapp://send?phone=${item.phoneNumber}`)}>
                                    <Text style={{ marginHorizontal: 8 }}><SvgIcons.Whatsapp /></Text>
                                </TouchableOpacity>
                            </View>
                        </View>

                        <View style={{ flexDirection: "row", justifyContent: "space-between" }}>
                            <Text style={{color:"black"}}>
                                {item.phoneNumber} {item.type == 'UNKNOWN' ? '' : `(${item.duration}sec)`} <Icon
                                    name={item.type == 'INCOMING' ? 'phone-incoming' : item.type == 'OUTGOING' ? 'phone-outgoing' : 'phone-missed'}
                                    color={item.type == 'INCOMING' ? 'green' : item.type == 'OUTGOING' ? 'deepskyblue' : 'red'} />
                            </Text>
                            <Text style={{color:"black"}}> {item.dateTime} </Text>
                        </View>
                    </View>
                )
            }
            }
        />
    </View>
)

}

could you please suggest me a way how can i avoid this warning. Thanks

Version

0.69.3

Output of npx react-native info

System: OS: Windows 10 10.0.19044 CPU: (4) x64 Intel(R) Core(TM) i5-7400 CPU @ 3.00GHz Memory: 510.30 MB / 7.89 GB Binaries: Node: 16.16.0 - C:\Program Files\nodejs\node.EXE
Yarn: Not Found npm: 8.11.0 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found SDKs: Android SDK: API Levels: 31, 32, 33 Build Tools: 30.0.3, 31.0.0, 33.0.0 System Images: android-31 | Google APIs Intel x86 Atom_64, android-31 | Google Play Intel x86 Atom_64 Android NDK: Not Found Windows SDK: Not Found IDEs: Android Studio: AI-212.5712.43.2112.8609683 Visual Studio: 17.2.32630.192 (Visual Studio Community 2022) Languages: Java: 17.0.4 npmPackages: @react-native-community/cli: Not Found react: 18.0.0 => 18.0.0 react-native: 0.69.3 => 0.69.3 react-native-windows: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

1

Snack, code example, screenshot, or link to a repository

Screenshot

nguptaesaral avatar Aug 10 '22 11:08 nguptaesaral

Same issue here when rendering this item:

<TouchableOpacity
  key={item.id}
  onPress={async () => setResult(await getPickedImageResult(item))}>
  <Image
    style={{ width: size, height: size }}
    source={{ uri: item.uri, width: item.width, height: item.height }}
  />
</TouchableOpacity>

For me the warning triggers after some scrolling, sometimes after rendering 70 items, sometimes after more.

Changing the TouchableOpacity to a Pressable component no more triggers the warning so I assume this is caused by TouchableOpacity?

purplnay avatar Aug 30 '22 08:08 purplnay

Yeah this seems to be caused by a change to TouchableOpacity in React Native 0.69....

https://github.com/facebook/react-native/commit/3eddc9abb70eb54209c68aab7dbd69e363cc7b29

(flattenStyle(prevProps.style)?.opacity !==
        flattenStyle(this.props.style)?.opacity) !==
        undefined

is always going to evaluate to true, therefore calling this._opacityInactive(250); as many times as the component is (re)rendered.

Quick fix: remove the !== undefined from node_modules/react-native/Libraries/Components/Touchable/TouchableOpacity.js then run npx patch-package react-native

mjmasn avatar Nov 09 '22 15:11 mjmasn

I get a similar error message but with react-native 0.68

VirtualizedList: You have a large list that is slow to update - make sure your renderItem function renders components that follow React performance best practices like PureComponent, shouldComponentUpdate, etc. Object {
  "contentLength": 6300.1904296875,
  "dt": 577,
  "prevDt": 3427,
}

Please report: Excessive number of pending callbacks: 501. Some pending callbacks that might have leaked by never being called from native code: {"108821":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"108824":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"108828":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"108831":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"108834":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"108838":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"108841":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"108844":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"108848":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"108851":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"108855":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"108864":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111562":{"module":"UIManager","method":"measure"},"111563":{"module":"UIManager","method":"measure"},"111634":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111638":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111641":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111644":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111648":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111651":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111654":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111658":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111661":{},"111664":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111668":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111671":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111674":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111678":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111681":{},"111685":{},"111689":{},"111693":{},"111697":{},"111701":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111705":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111709":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111713":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111717":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111721":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111725":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111729":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111738":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111747":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111751":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111760":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111769":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111778":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111782":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111791":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"111800":{"module":"NativeAnimatedModule","method":"startAnimatingNode"},"...(truncated keys)...":451}
at node_modules/react-native/Libraries/Utilities/warnOnce.js:27:2 in warnOnce
- ... 34 more stack frames from framework internals

Charles-Johnson avatar Dec 07 '22 09:12 Charles-Johnson

@mjmasn that typo seems to be addressed here: https://github.com/facebook/react-native/pull/35387

FrikkieSnyman avatar Dec 20 '22 14:12 FrikkieSnyman

@FrikkieSnyman yep 👍 I imagine it'll be released with React Native 0.72 unless it gets cherry picked onto 0.71 in the meantime

mjmasn avatar Dec 20 '22 14:12 mjmasn

With react-native 0.71.3 (expo sdk48) it is not fixed, so you still have to patch it.

patches/react-native+0.71.3.patch
diff --git a/node_modules/react-native/Libraries/Components/Touchable/TouchableOpacity.js b/node_modules/react-native/Libraries/Components/Touchable/TouchableOpacity.js
index 2aef4e8..152c807 100644
--- a/node_modules/react-native/Libraries/Components/Touchable/TouchableOpacity.js
+++ b/node_modules/react-native/Libraries/Components/Touchable/TouchableOpacity.js
@@ -302,8 +302,7 @@ class TouchableOpacity extends React.Component<Props, State> {
     if (
       this.props.disabled !== prevProps.disabled ||
       (flattenStyle(prevProps.style)?.opacity !==
-        flattenStyle(this.props.style)?.opacity) !==
-        undefined
+        flattenStyle(this.props.style)?.opacity)
     ) {
       this._opacityInactive(250);
     }

linaia avatar Mar 29 '23 10:03 linaia

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jan 13 '24 05:01 github-actions[bot]

It's fixed in 0.72.6 (used by expo sdk49)

if (
      this.props.disabled !== prevProps.disabled ||
      // $FlowFixMe[underconstrained-implicit-instantiation]
      flattenStyle(prevProps.style)?.opacity !==
        // $FlowFixMe[underconstrained-implicit-instantiation]
        flattenStyle(this.props.style)?.opacity
    ) {
      this._opacityInactive(250);
    }

You can close the issue.

linaia avatar Jan 15 '24 16:01 linaia

Any updates? Experiencing this in v0.73.4

tomerh2001 avatar Feb 21 '24 17:02 tomerh2001

Any updates? Experiencing this in v0.73.4

Use Pressable instead of TouchableOpacity.

nguptaesaral avatar Feb 23 '24 06:02 nguptaesaral

Same in v0.73.6, change TouchableOpacity to Pressable, didn't work at all

saczx avatar Mar 17 '24 20:03 saczx

seeing same error in v0.73.8 for <TextInput /> given to ListHeaderComponent

yummyelin avatar Jun 27 '24 18:06 yummyelin