Commit 574a2f9
fix(new-arch): align TurboModule openPicker signature across iOS, Android, and JS
Under React Native's new architecture, the TurboModule runtime enforces
strict argument-count parity between the JS-side spec, the platform
native module, and every JS caller. `react-native-date-picker`
currently has three sources of truth for `openPicker` and they
disagree:
| Layer | Args |
|-----------------------------------------------|---------------|
| iOS native (`ios/RNDatePickerManager.mm`) | 3 (uses cbs) |
| Android native newarch (`DatePickerModule`) | 1 |
| Codegen spec (`src/fabric/NativeRNDatePicker.ts`) | 1 |
| JS caller iOS (`src/modal.js`) | 3 |
| JS caller Android (`src/modal.js`) | 1 |
So one of the two platforms is always wrong:
- With the spec at 1 arg, the iOS caller's 3-arg invocation is over by
two (RN currently permits this, but it is undocumented behaviour and
fails strict tooling).
- If a consumer patches the spec to 3 args to match iOS (a common
workaround once they hit `TurboModule method "openPicker" called with
1 arguments (expected argument count: 3)`), the Android JS caller
starts crashing on every modal open.
This PR makes all five layers agree on 3 args:
- `src/fabric/NativeRNDatePicker.ts` — spec now declares
`openPicker(props, onConfirm, onCancel)`.
- `android/src/newarch/java/.../DatePickerModule.java` — accepts
`Callback onConfirm, Callback onCancel` and ignores them; Android
continues to deliver confirm/cancel via the existing
`RCTDeviceEventEmitter` flow.
- `src/modal.js` — Android branch now passes two no-op callbacks so
the 3-arg signature is honoured on both platforms.
iOS behaviour is unchanged at runtime (its native side already takes
3 args and uses them). Android behaviour is unchanged at runtime (the
callbacks are unused; events still flow via the emitter listeners
registered in `useModal`).
Encountered downstream in a React Native 0.85 + new-arch banking app
where opening any modal date picker (transaction filter date range,
loan payment day) on Android crashed with the strict arg-count error.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 1dcf1c1 commit 574a2f9
4 files changed
Lines changed: 25 additions & 5 deletions
File tree
- android/src/newarch/java/com/henninghall/date_picker
- src
- fabric
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
32 | 39 | | |
33 | 40 | | |
34 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
28 | 32 | | |
29 | 33 | | |
30 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
79 | 84 | | |
80 | | - | |
| 85 | + | |
81 | 86 | | |
82 | 87 | | |
83 | 88 | | |
| |||
0 commit comments