Skip to content

Commit 487f7f5

Browse files
committed
feat: upgrade package to latest react-native version
1 parent ab101ee commit 487f7f5

10 files changed

Lines changed: 636 additions & 1955 deletions

File tree

babel.config.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,14 @@
1515
*/
1616

1717
module.exports = {
18-
presets: ['module:@react-native/babel-preset'],
18+
overrides: [
19+
{
20+
exclude: /\/node_modules\//,
21+
presets: ['module:react-native-builder-bob/babel-preset'],
22+
},
23+
{
24+
include: /\/node_modules\//,
25+
presets: ['module:@react-native/babel-preset'],
26+
},
27+
],
1928
};

eslint.config.mjs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { fixupConfigRules } from '@eslint/compat';
18+
import { FlatCompat } from '@eslint/eslintrc';
19+
import js from '@eslint/js';
20+
import prettier from 'eslint-plugin-prettier';
21+
import { defineConfig } from 'eslint/config';
22+
import path from 'node:path';
23+
import { fileURLToPath } from 'node:url';
24+
25+
const __filename = fileURLToPath(import.meta.url);
26+
const __dirname = path.dirname(__filename);
27+
const compat = new FlatCompat({
28+
baseDirectory: __dirname,
29+
recommendedConfig: js.configs.recommended,
30+
allConfig: js.configs.all,
31+
});
32+
33+
export default defineConfig([
34+
{
35+
extends: fixupConfigRules(compat.extends('@react-native', 'prettier')),
36+
plugins: { prettier },
37+
rules: {
38+
'react/react-in-jsx-scope': 'off',
39+
'prettier/prettier': 'error',
40+
},
41+
},
42+
{
43+
ignores: ['node_modules/', 'lib/'],
44+
},
45+
]);

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"react-native-gesture-handler": "2.25.0",
3030
"react-native-permissions": "^5.1.0",
3131
"react-native-safe-area-context": "^5.5.2",
32-
"react-native-screens": "^4.15.4",
32+
"react-native-screens": "4.11.1",
3333
"react-native-select-dropdown": "^4.0.1",
3434
"react-native-snackbar": "^2.8.0"
3535
},

package.json

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,27 @@
5959
},
6060
"devDependencies": {
6161
"@commitlint/config-conventional": "^19.2.2",
62+
"@eslint/compat": "^1.2.7",
63+
"@eslint/eslintrc": "^3.3.0",
64+
"@eslint/js": "^9.22.0",
6265
"@evilmartians/lefthook": "^1.5.0",
63-
"@react-native/eslint-config": "^0.74.83",
64-
"@react-native/typescript-config": "0.81.1",
65-
"@testing-library/react-native": "^12.5.0",
66-
"@types/react": "18.2.6",
66+
"@react-native/babel-preset": "^0.81.1",
67+
"@react-native/eslint-config": "^0.78.0",
68+
"@react-native/typescript-config": "^0.81.1",
69+
"@testing-library/react-native": "^13.3.3",
70+
"@types/react": "19.1.0",
6771
"commitlint": "^19.3.0",
6872
"del-cli": "^5.1.0",
69-
"eslint": "^8.51.0",
70-
"eslint-config-google": "^0.14.0",
71-
"eslint-config-prettier": "^9.0.0",
72-
"eslint-plugin-prettier": "^5.2.1",
73-
"eslint-plugin-testing-library": "^6.2.2",
73+
"eslint": "^9.22.0",
74+
"eslint-config-prettier": "^10.1.1",
75+
"eslint-plugin-prettier": "^5.2.3",
7476
"prettier": "^3.3.3",
75-
"react": "18.2.0",
76-
"react-native": "0.74.1",
77-
"react-native-builder-bob": "^0.29.0",
78-
"react-test-renderer": "18.2.0",
77+
"react": "19.1.0",
78+
"react-native": "0.81.1",
79+
"react-native-builder-bob": "^0.40.13",
80+
"react-test-renderer": "^19.1.0",
7981
"turbo": "^1.10.7",
80-
"typescript": ">=4.3.5 <5.9.0"
82+
"typescript": "^5.8.3"
8183
},
8284
"peerDependencies": {
8385
"react": "*",
@@ -92,34 +94,6 @@
9294
"@commitlint/config-conventional"
9395
]
9496
},
95-
"eslintConfig": {
96-
"root": true,
97-
"extends": [
98-
"@react-native",
99-
"google",
100-
"prettier"
101-
],
102-
"rules": {
103-
"no-unused-vars": "off",
104-
"@typescript-eslint/no-unused-vars": 2,
105-
"prettier/prettier": [
106-
"error",
107-
{
108-
"arrowParens": "avoid",
109-
"quoteProps": "consistent",
110-
"singleQuote": true,
111-
"tabWidth": 2,
112-
"trailingComma": "es5",
113-
"useTabs": false
114-
}
115-
]
116-
}
117-
},
118-
"eslintIgnore": [
119-
"node_modules/",
120-
"coverage/",
121-
"lib/"
122-
],
12397
"prettier": {
12498
"arrowParens": "avoid",
12599
"quoteProps": "consistent",

src/auto/useNavigationAuto.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import type {
3333
} from '../maps';
3434
import { useMemo } from 'react';
3535

36-
const { NavAutoEventDispatcher, NavAutoModule } = NativeModules;
36+
const { NavAutoModule } = NativeModules;
3737

3838
export const useNavigationAuto = (): {
3939
mapViewAutoController: MapViewAutoController;
@@ -42,7 +42,7 @@ export const useNavigationAuto = (): {
4242
removeAllListeners: () => void;
4343
} => {
4444
const moduleListenersHandler = useModuleListeners<NavigationAutoCallbacks>(
45-
NavAutoEventDispatcher,
45+
'NavAutoEventDispatcher',
4646
['onAutoScreenAvailabilityChanged', 'onCustomNavigationAutoEvent']
4747
);
4848

src/navigation/navigation/useNavigationController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import {
3535
} from './types';
3636
import { getRouteStatusFromStringValue } from '../navigationView';
3737

38-
const { NavModule, NavEventDispatcher } = NativeModules;
38+
const { NavModule } = NativeModules;
3939

4040
export const useNavigationController = (
4141
termsAndConditionsDialogOptions: TermsAndConditionsDialogOptions,
@@ -57,7 +57,7 @@ export const useNavigationController = (
5757
};
5858

5959
const moduleListenersHandler = useModuleListeners<NavigationCallbacks>(
60-
NavEventDispatcher,
60+
'NavEventDispatcher',
6161
[
6262
'onStartGuidance',
6363
'onArrival',

src/shared/useModuleListeners.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
import { useRef, useCallback, useEffect } from 'react';
1818
import {
1919
NativeEventEmitter,
20-
type EmitterSubscription,
21-
type NativeModule,
20+
NativeModules,
21+
type EventSubscription,
2222
} from 'react-native';
2323

2424
type ListenerMap<T> = {
@@ -30,7 +30,7 @@ type ListenerMap<T> = {
3030
export const useModuleListeners = <
3131
T extends { [K in keyof T]: ((...args: any[]) => void) | undefined },
3232
>(
33-
dispatcher: NativeModule,
33+
dispatcher: keyof NativeModules,
3434
eventTypes: Array<keyof T>,
3535
eventTransformer?: <K extends keyof T>(
3636
eventKey: K,
@@ -43,11 +43,13 @@ export const useModuleListeners = <
4343
} => {
4444
const listenersRef = useRef<ListenerMap<T>>({});
4545
const eventEmitterRef = useRef<NativeEventEmitter | null>(null);
46-
const subsRef = useRef<Record<string, EmitterSubscription | undefined>>({});
46+
const subsRef = useRef<Record<string, EventSubscription | undefined>>({});
4747

4848
const getEventEmitter = useCallback(() => {
4949
if (!eventEmitterRef.current) {
50-
eventEmitterRef.current = new NativeEventEmitter(dispatcher);
50+
eventEmitterRef.current = new NativeEventEmitter(
51+
NativeModules[dispatcher]
52+
);
5153
}
5254
return eventEmitterRef.current;
5355
}, [dispatcher]);
@@ -92,7 +94,6 @@ export const useModuleListeners = <
9294
eventTypes.forEach(eventType => {
9395
const name = String(eventType);
9496
const handler = wrappedListeners[eventType]!;
95-
// No Platform check needed here anymore! ✅
9697
const sub = getEventEmitter().addListener(name, handler);
9798
subsRef.current[name] = sub;
9899
});

src/shared/viewManager.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import {
2121
type HostComponent,
2222
type ViewProps,
2323
} from 'react-native';
24-
import type { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
2524
import type { LatLng } from '.';
2625
import type { Circle, GroundOverlay, Marker, Polygon, Polyline } from '../maps';
26+
import type { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypesNamespace';
2727

2828
// NavViewManager is responsible for managing both the regular map fragment as well as the navigation map view fragment.
2929
export const viewManagerName =
@@ -43,16 +43,21 @@ export const sendCommand = (
4343
try {
4444
UIManager.dispatchViewManagerCommand(
4545
viewId,
46-
Platform.OS === 'android' ? command.toString() : command,
46+
Platform.OS === 'android' ? (command.toString() as any) : command,
4747
args
4848
);
4949
} catch (exception) {
5050
console.error(exception);
5151
}
5252
};
5353

54-
export const commands =
55-
UIManager.getViewManagerConfig(viewManagerName).Commands;
54+
interface ViewManagerConfig {
55+
Commands: { [key: string]: number };
56+
}
57+
58+
export const commands = (
59+
UIManager.getViewManagerConfig(viewManagerName) as ViewManagerConfig
60+
).Commands;
5661

5762
export interface NativeNavViewProps extends ViewProps {
5863
flex?: number | undefined;

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@
2626
"strict": true,
2727
"target": "ESNext",
2828
"verbatimModuleSyntax": true
29-
}
29+
},
30+
"exclude": ["lib"]
3031
}

0 commit comments

Comments
 (0)