Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I get the parameters in the renderItem? #20

Open
Innei opened this issue Jan 23, 2025 · 2 comments
Open

How do I get the parameters in the renderItem? #20

Innei opened this issue Jan 23, 2025 · 2 comments

Comments

@Innei
Copy link

Innei commented Jan 23, 2025

According to the document, renderItem should be consistent with rn and obtain the item and index parameters. However, this is not provided in the code.

I am not sure how to correctly render the correct data based on the item.

Image

Image

@FightFarewellFearless
Copy link

const stringify = (str: string) => `{{${str}}}`;

@azimgd
Copy link
Owner

azimgd commented Jan 26, 2025

Hey @Innei, the readme docs aren’t correct and I’ll get them updated soon.

TS declaration and example from @FightFarewellFearless is accurate. The renderItem function doesn’t pass data or index as arguments, and doesn't support dynamic components or react effects since elements are created natively. To trigger changes when an item is pressed, you can use this to get the index of the pressed item:

const elementDataIndex = __NATIVE_getRegistryElementMapping(event.nativeEvent.target);

To render text or images, use the template notation shown above:

// [{keyA: { keyB: string }}]
{{keyA.keyB}}

You can also check the working version in the example folder. Let me know if you need more help. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants