Skip to content

Commit 0e25040

Browse files
authored
feat: upgrade react native to 79.2 (#72)
1 parent 6ff29e8 commit 0e25040

File tree

18 files changed

+3919
-5828
lines changed

18 files changed

+3919
-5828
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ override func application(_ application: UIApplication, supportedInterfaceOrient
135135
}
136136
```
137137

138+
Note: if you are targeting react-native > 79.x, you can omit the `override` keyword.
139+
138140
If you need help, you can check the example project.
139141

140142
## Usage

babel.config.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
module.exports = {
2-
presets: ['module:@react-native/babel-preset'],
2+
overrides: [
3+
{
4+
exclude: /\/node_modules\//,
5+
presets: ['module:react-native-builder-bob/babel-preset'],
6+
},
7+
{
8+
include: /\/node_modules\//,
9+
presets: ['module:@react-native/babel-preset'],
10+
},
11+
],
312
};

eslint.config.mjs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { fixupConfigRules } from '@eslint/compat';
2+
import { FlatCompat } from '@eslint/eslintrc';
3+
import js from '@eslint/js';
4+
import prettier from 'eslint-plugin-prettier';
5+
import { defineConfig } from 'eslint/config';
6+
import path from 'node:path';
7+
import { fileURLToPath } from 'node:url';
8+
9+
const __filename = fileURLToPath(import.meta.url);
10+
const __dirname = path.dirname(__filename);
11+
const compat = new FlatCompat({
12+
baseDirectory: __dirname,
13+
recommendedConfig: js.configs.recommended,
14+
allConfig: js.configs.all,
15+
});
16+
17+
export default defineConfig([
18+
{
19+
extends: fixupConfigRules(compat.extends('@react-native', 'prettier')),
20+
plugins: { prettier },
21+
rules: {
22+
'react/react-in-jsx-scope': 'off',
23+
'prettier/prettier': [
24+
'error',
25+
{
26+
quoteProps: 'consistent',
27+
singleQuote: true,
28+
tabWidth: 2,
29+
trailingComma: 'es5',
30+
useTabs: false,
31+
},
32+
],
33+
},
34+
},
35+
{
36+
ignores: [
37+
'node_modules/',
38+
'lib/'
39+
],
40+
},
41+
]);

example/Gemfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ ruby ">= 2.6.10"
66
# Exclude problematic versions of cocoapods and activesupport that causes build failures.
77
gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
88
gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
9+
gem 'xcodeproj', '< 1.26.0'
910
gem 'concurrent-ruby', '< 1.3.4'
1011

11-
gem 'xcodeproj', '< 1.26.0'
12+
# Ruby 3.4.0 has removed some libraries from the standard library.
13+
gem 'bigdecimal'
14+
gem 'logger'
15+
gem 'benchmark'
16+
gem 'mutex_m'

example/Gemfile.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ GEM
1818
json (>= 1.5.1)
1919
atomos (0.1.3)
2020
base64 (0.2.0)
21+
benchmark (0.2.1)
22+
bigdecimal (3.1.3)
2123
claide (1.1.0)
2224
cocoapods (1.14.3)
2325
addressable (~> 2.8)
@@ -69,8 +71,10 @@ GEM
6971
i18n (1.14.5)
7072
concurrent-ruby (~> 1.0)
7173
json (2.7.2)
74+
logger (1.5.3)
7275
minitest (5.23.0)
7376
molinillo (0.8.0)
77+
mutex_m (0.1.2)
7478
nanaimo (0.3.0)
7579
nap (1.1.0)
7680
netrc (0.11.0)
@@ -98,8 +102,12 @@ PLATFORMS
98102

99103
DEPENDENCIES
100104
activesupport (>= 6.1.7.5, != 7.1.0)
105+
benchmark
106+
bigdecimal
101107
cocoapods (>= 1.13, != 1.15.1, != 1.15.0)
102108
concurrent-ruby (< 1.3.4)
109+
logger
110+
mutex_m
103111
xcodeproj (< 1.26.0)
104112

105113
RUBY VERSION
122 Bytes
Binary file not shown.

example/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

example/android/gradlew

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ fi
205205
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
206206

207207
# Collect all arguments for the java command:
208-
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
208+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
209209
# and any embedded shellness will be escaped.
210210
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
211211
# treated as '${Hostname}' itself on the command line.

example/babel.config.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
const path = require('path');
2-
const pak = require('../package.json');
2+
const { getConfig } = require('react-native-builder-bob/babel-config');
3+
const pkg = require('../package.json');
34

4-
module.exports = {
5-
presets: ['module:@react-native/babel-preset'],
6-
plugins: [
7-
[
8-
'module-resolver',
9-
{
10-
extensions: ['.tsx', '.ts', '.js', '.json'],
11-
alias: {
12-
[pak.name]: path.join(__dirname, '..', pak.source),
13-
},
14-
},
15-
],
16-
],
17-
};
5+
const root = path.resolve(__dirname, '..');
6+
7+
module.exports = getConfig(
8+
{
9+
presets: ['module:@react-native/babel-preset'],
10+
},
11+
{ root, pkg }
12+
);

example/ios/OrientationDirectorExample/AppDelegate.swift

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,51 @@ import UIKit
22
import React
33
import React_RCTAppDelegate
44
import ReactAppDependencyProvider
5-
5+
66
@main
7-
class AppDelegate: RCTAppDelegate {
8-
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
9-
self.moduleName = "OrientationDirectorExample"
10-
self.dependencyProvider = RCTAppDependencyProvider()
11-
12-
// You can add your custom initial props in the dictionary below.
13-
// They will be passed down to the ViewController used by React Native.
14-
self.initialProps = [:]
15-
16-
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
7+
class AppDelegate: UIResponder, UIApplicationDelegate {
8+
var window: UIWindow?
9+
10+
var reactNativeDelegate: ReactNativeDelegate?
11+
var reactNativeFactory: RCTReactNativeFactory?
12+
13+
func application(
14+
_ application: UIApplication,
15+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
16+
) -> Bool {
17+
let delegate = ReactNativeDelegate()
18+
let factory = RCTReactNativeFactory(delegate: delegate)
19+
delegate.dependencyProvider = RCTAppDependencyProvider()
20+
21+
reactNativeDelegate = delegate
22+
reactNativeFactory = factory
23+
24+
window = UIWindow(frame: UIScreen.main.bounds)
25+
26+
factory.startReactNative(
27+
withModuleName: "OrientationDirectorExample",
28+
in: window,
29+
launchOptions: launchOptions
30+
)
31+
32+
return true
1733
}
18-
34+
35+
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
36+
return OrientationDirector.getSupportedInterfaceOrientationsForWindow()
37+
}
38+
}
39+
40+
class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
1941
override func sourceURL(for bridge: RCTBridge) -> URL? {
2042
self.bundleURL()
2143
}
22-
44+
2345
override func bundleURL() -> URL? {
2446
#if DEBUG
2547
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
2648
#else
2749
Bundle.main.url(forResource: "main", withExtension: "jsbundle")
2850
#endif
2951
}
30-
31-
override func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
32-
return OrientationDirector.getSupportedInterfaceOrientationsForWindow()
33-
}
3452
}

0 commit comments

Comments
 (0)