Commit d4f1a4c
authored
fix: access before initialization error (#1342)
## 📜 Description
Fixed error.
```sh
Metro error: Cannot access 'clampedScrollTarget' before initialization
ReferenceError: Cannot access 'clampedScrollTarget' before initialization
```
## 💡 Motivation and Context
It seems like `export function` produces:
<img width="774" height="673" alt="image"
src="https://github.com/user-attachments/assets/6faf2e2d-de9c-4565-8adb-dba1c5cdc13d"
/>
While `export const` produces:
<img width="1000" height="663" alt="image"
src="https://github.com/user-attachments/assets/23cf8661-d418-4e55-8bf9-4314d591d732"
/>
...
<img width="1069" height="323" alt="image"
src="https://github.com/user-attachments/assets/ac30e296-7afc-4ec7-891f-bbe774ae6457"
/>
So with first case we try to export function that hasn't been declared
(though `function` should be hoisted?). Anyway across the package we
often use `arrow functions` and it doesn't cause issues, so let's
continue to use it.
In this PR I re-worked `helpers` file and used arrow functions instead
of regular functions.
## 📢 Changelog
<!-- High level overview of important changes -->
<!-- For example: fixed status bar manipulation; added new types
declarations; -->
<!-- If your changes don't affect one of platform/language below - then
remove this platform/language -->
### JS
- use `export const` instead of `export function`;
- use arrow functions in `helpers`;
## 🤔 How Has This Been Tested?
Tested in LegendList repo.
## 📸 Screenshots (if appropriate):
|Before|After|
|-------|-----|
|<img width="774" height="673" alt="image"
src="https://github.com/user-attachments/assets/6faf2e2d-de9c-4565-8adb-dba1c5cdc13d"
/>|<img width="1000" height="663" alt="image"
src="https://github.com/user-attachments/assets/23cf8661-d418-4e55-8bf9-4314d591d732"
/>|
## 📝 Checklist
- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed1 parent 8393ee2 commit d4f1a4c
1 file changed
Lines changed: 15 additions & 15 deletions
Lines changed: 15 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
| 143 | + | |
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
| 150 | + | |
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
168 | | - | |
| 168 | + | |
0 commit comments