Could not find attached view in own tree

When I scroll down and then up a large list of items in a SectionList, I get an error. I am wondering if anyone had this problem before, because I could not find any documents on it.

enter image description here

+18
source share
2 answers

The problem in my case was that I had items with the same key. Setting a unique key fixed this.

{items.map(item => {
    <Item key={item.uniqueId}/>
})
+1
source

Is your AnimatedComponent Animated.Image? I had the same error, and I realized that the problem was how I imported the image.

Error

in./assets/index.js:

// ...
import profilePlaceholder from './profilePlaceholder.png';
// ...
export { profilePlaceholder, ...(other images) }

in component:

import { profilePlaceholder } from '../../../assets/images';

(...)
<Animated.Image
    style={imageStyle}
    source={profilePlaceholder}
    resizeMode='cover'
/>

works fine

in./assets/index.js:

// ...
// import profilePlaceholder from './profilePlaceholder.png';
// ...
// export { profilePlaceholder, ...(other images) }

in component:

import profilePlaceholder from '../../../assets/images//profilePlaceholder.png'; <-- changed this

(...)
<Animated.Image
    style={imageStyle}
    source={profilePlaceholder}
    resizeMode='cover'
/>

Hope this helps.

0
source

Source: https://habr.com/ru/post/1692150/


All Articles