IjzerenHein / IjzerenHein/react-navigation-shared-element

Keeps rerendering ListView tab

Open
#226 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.3k
Forks
125
PR merge metrics
No merged PRs in 30d

Description

Please also see this stackoverflow question: https://stackoverflow.com/questions/70857346/shared-navigation-infinite-loop-react-native.

The ListView in the title references here to Home component.

```
const HomeTab = () => {
const Stack = createSharedElementStackNavigator();
return (


{
//Code in here is never executed
return [route.params.id];
}}
/>


);
};
```

```
const Home = ({ navigation }) => {
const [APIHook, setAPIHook] = useState(null);

useEffect(() => {
fetchAPIData();
}, []);

const fetchAPIData = async () => {
//Gets the data
}

if (!APIData){
return (Loading);
}

return (
renderDetail(navigation, item)} keyExtractor={(item) => item.id.toString()}/>
);
};

export default Home;
```

```
export default renderDetail = (navigation, item) => (
...
navigation.push("Detail", item)}>




...
);
```

```
const Detail= ({ route, navigation }) => {
let detail = route.params;
return (
...



...
)
};
export default Detail;
```

When clicking om image on Home program gets stuck in infinite loop: first it renders the HomeTab component again -> Home component -> Detail (renderDetail is not rendered again in this loop).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the linked Stack Overflow question and trace the HomeTab, Home, renderDetail, and Detail components shown in the report. Reproduce the navigation from Home to Detail and inspect the render cycle around the shared-element configuration. Done means the navigation no longer enters the infinite rerender loop and the sharedElements callback is reached.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.