callstack / callstack/react-native-pager-view
useMemo inside useState in example
- Langage dominant
- TypeScript
- Étoiles
- 3.4k
- Forks
- 476
- Merge moyen
- 10 j 21 h
- PR mergées (30 j)
- 2
Description
## Ask your Question
There's a `useNavigationPanel` hook in the hook folder of the example project. I was trying to get deep in how to use the react-native-pager-view and I saw this [useMemo](https://github.com/callstack/react-native-pager-view/blob/2afcbf9bcfbfad0bee90c66c344f5cfebcf9836a/example/src/hook/useNavigationPanel.ts#L28) as the **initializer of useState.**
Is it a mistake? What kind of syntax is it and what is the reason?
As far as I know, the `useState` initializer executes just once before the first render and will not execute again unless the component remounts.
So if it's on purpose, then please explain it. Otherwise, I can create a PR and change it to a normal `useState`
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Start with example/src/hook/useNavigationPanel.ts and inspect the useMemo call linked in the issue as the useState initializer. Compare that initializer with the surrounding hook usage and the example’s expected behavior. Done means the initializer’s intent is established and the example either retains it with an explanation or uses the simpler form requested.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- react-native, typescript
- Domaine
- mobile
- Type d'issue
- Refactorisation
- Difficulté
- 1/5
- Temps estimé
- 1-3 heures
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 48/100