meliorence / meliorence/react-native-snap-carousel

Pass class props to renderItem function

Open
#748 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
10.5k
Forks
2.3k
PR merge metrics
No merged PRs in 30d

Description

Feature request / Question

I am working in react native and trying to Pass the navigation prop of my class component to the component being rendered in renderItem so it can be used as a navigation button, but it seems that renderItem loses the class scope so this.props.navigation no longer works inside the function called by renderItem as 'this' is undefined. I could try pushing the navigation prop into the item data, which i imagine will work, but it feels like a hacky solution and i feel like there should be a standard method to do this. I cant see an obvious way to do it, if i have missed it my apologies.

Thanks

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names only the renderItem entry point and React Native navigation props; no file or test is provided. Start by locating the renderItem API and its existing usage, then define whether class props should be available to the rendered component and verify the agreed behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
frontend, mobile
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.