Skip to content

Commit 9f00e71

Browse files
onmotionTheHypnoo
andauthored
React 19 support (#170)
* Working with React 19 (#168) * fix: update MutableRefObject import to use React namespace * fix: update dependencies in useEffect hooks for better stability and clean up props spreading * fix: update devDependencies and dependencies for compatibility with latest versions * fix: update dependencies and scripts for compatibility with latest versions * fix: update Android build configuration for compatibility and enable new architecture * fix: update dependencies in yarn * fix: update type definitions * chore: rebase (#169) * fix: typo * fix: keyboardAvoidingView bahavior --------- Co-authored-by: Sergi Gonzalez <[email protected]>
1 parent 9c3f7f2 commit 9f00e71

File tree

44 files changed

+4543
-4972
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+4543
-4972
lines changed

example/.bundle/config

-2
This file was deleted.

example/App.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const App = () => {
3838
<StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
3939
<KeyboardAvoidingView
4040
style={styles.scrollContainer}
41-
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
41+
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
4242
enabled>
4343
<ScrollView
4444
nestedScrollEnabled

example/Gemfile

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
source 'https://rubygems.org'
1+
source "https://rubygems.org"
22

33
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
44
ruby ">= 2.6.10"
55

66
# Exclude problematic versions of cocoapods and activesupport that causes build failures.
7-
gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
8-
gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
7+
gem "cocoapods", ">= 1.13", "!= 1.15.0", "!= 1.15.1"
8+
gem "activesupport", ">= 6.1.7.5", "!= 7.1.0"
9+
gem "xcodeproj", "< 1.26.0"
10+
gem "concurrent-ruby", "< 1.3.4"
11+
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/__tests__/App.test.tsx

+5-9
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22
* @format
33
*/
44

5-
import 'react-native'
65
import React from 'react'
7-
8-
// Note: import explicitly to use the types shiped with jest.
9-
import { it } from '@jest/globals'
10-
11-
// Note: test renderer must be required after react-native.
12-
import renderer from 'react-test-renderer'
6+
import ReactTestRenderer from 'react-test-renderer'
137
import App from '../App'
148

15-
it('renders correctly', () => {
16-
renderer.create(<App />)
9+
test('renders correctly', async () => {
10+
await ReactTestRenderer.act(() => {
11+
ReactTestRenderer.create(<App />)
12+
})
1713
})

example/android/app/build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,23 @@ def enableProguardInReleaseBuilds = false
6363
* The preferred build flavor of JavaScriptCore (JSC)
6464
*
6565
* For example, to use the international variant, you can use:
66-
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
66+
* `def jscFlavor = io.github.react-native-community:jsc-android-intl:2026004.+`
6767
*
6868
* The international variant includes ICU i18n library and necessary data
6969
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
7070
* give correct results when using with locales other than en-US. Note that
7171
* this variant is about 6MiB larger per architecture than default.
7272
*/
73-
def jscFlavor = 'org.webkit:android-jsc:+'
73+
def jscFlavor = 'io.github.react-native-community:jsc-android:2026004.+'
7474

7575
android {
7676
ndkVersion rootProject.ext.ndkVersion
7777
buildToolsVersion rootProject.ext.buildToolsVersion
7878
compileSdk rootProject.ext.compileSdkVersion
7979

80-
namespace "com.autocomletedropdownplayground"
80+
namespace "com.autocompletedropdownplayground"
8181
defaultConfig {
82-
applicationId "com.autocomletedropdownplayground"
82+
applicationId "com.autocompletedropdownplayground"
8383
minSdkVersion rootProject.ext.minSdkVersion
8484
targetSdkVersion rootProject.ext.targetSdkVersion
8585
versionCode 1

example/android/app/src/main/java/com/autocomletedropdownplayground/MainActivity.kt renamed to example/android/app/src/main/java/com/autocompletedropdownplayground/MainActivity.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.autocomletedropdownplayground
1+
package com.autocompletedropdownplayground
22

33
import com.facebook.react.ReactActivity
44
import com.facebook.react.ReactActivityDelegate
@@ -11,7 +11,7 @@ class MainActivity : ReactActivity() {
1111
* Returns the name of the main component registered from JavaScript. This is used to schedule
1212
* rendering of the component.
1313
*/
14-
override fun getMainComponentName(): String = "AutocomleteDropdownPlayground"
14+
override fun getMainComponentName(): String = "AutocompleteDropdownPlayground"
1515

1616
/**
1717
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]

example/android/app/src/main/java/com/autocomletedropdownplayground/MainApplication.kt renamed to example/android/app/src/main/java/com/autocompletedropdownplayground/MainApplication.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.autocomletedropdownplayground
1+
package com.autocompletedropdownplayground
22

33
import android.app.Application
44
import com.facebook.react.PackageList
@@ -9,6 +9,7 @@ import com.facebook.react.ReactPackage
99
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
1010
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
1111
import com.facebook.react.defaults.DefaultReactNativeHost
12+
import com.facebook.react.soloader.OpenSourceMergedSoMapping
1213
import com.facebook.soloader.SoLoader
1314

1415
class MainApplication : Application(), ReactApplication {
@@ -34,7 +35,7 @@ class MainApplication : Application(), ReactApplication {
3435

3536
override fun onCreate() {
3637
super.onCreate()
37-
SoLoader.init(this, false)
38+
SoLoader.init(this, OpenSourceMergedSoMapping)
3839
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
3940
// If you opted-in for the New Architecture, we load the native entry point for this app.
4041
load()
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<resources>
2-
<string name="app_name">AutocomleteDropdownPlayground</string>
2+
<string name="app_name">AutocompleteDropdownPlayground</string>
33
</resources>

example/android/build.gradle

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
buildscript {
22
ext {
3-
buildToolsVersion = "34.0.0"
4-
minSdkVersion = 23
5-
compileSdkVersion = 34
6-
targetSdkVersion = 34
7-
ndkVersion = "26.1.10909125"
8-
kotlinVersion = "1.9.24"
3+
buildToolsVersion = "35.0.0"
4+
minSdkVersion = 24
5+
compileSdkVersion = 35
6+
targetSdkVersion = 35
7+
ndkVersion = "27.1.12297006"
8+
kotlinVersion = "2.0.21"
99
}
1010
repositories {
1111
google()

example/android/gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
3232
# your application. You should enable this flag either if you want
3333
# to write custom TurboModules/Fabric components OR use libraries that
3434
# are providing them.
35-
newArchEnabled=false
35+
newArchEnabled=true
3636

3737
# Use this property to enable or disable the Hermes JS engine.
3838
# If set to false, you will be using JSC instead.
252 Bytes
Binary file not shown.

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

+1-1
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.8-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

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -84,7 +86,7 @@ done
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
8688
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87-
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
8890

8991
# Use the maximum available, or set MAX_FD != -1 to use that value.
9092
MAX_FD=maximum
@@ -203,7 +205,7 @@ fi
203205
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204206

205207
# Collect all arguments for the java command:
206-
# * 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,
207209
# and any embedded shellness will be escaped.
208210
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209211
# treated as '${Hostname}' itself on the command line.

example/android/gradlew.bat

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
@rem See the License for the specific language governing permissions and
1414
@rem limitations under the License.
1515
@rem
16+
@rem SPDX-License-Identifier: Apache-2.0
17+
@rem
1618

1719
@if "%DEBUG%"=="" @echo off
1820
@rem ##########################################################################

example/android/settings.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
22
plugins { id("com.facebook.react.settings") }
33
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
4-
rootProject.name = 'AutocomleteDropdownPlayground'
4+
rootProject.name = 'AutocompleteDropdownPlayground'
55
include ':app'
66
includeBuild('../node_modules/@react-native/gradle-plugin')

example/app.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"name": "AutocomleteDropdownPlayground",
3-
"displayName": "AutocomleteDropdownPlayground"
2+
"name": "AutocompleteDropdownPlayground",
3+
"displayName": "AutocompleteDropdownPlayground"
44
}

example/components/ModalExample.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export const ModalExample = memo(() => {
1717
<SafeAreaView style={{ flex: 1 }}>
1818
<KeyboardAvoidingView
1919
style={{ flex: 1 }}
20-
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
21-
keyboardVerticalOffset={Platform.select({ ios: 75, default: 0 })}>
20+
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
21+
keyboardVerticalOffset={Platform.select({ ios: 75, default: 60 })}>
2222
<ScrollView
2323
nestedScrollEnabled
2424
keyboardDismissMode="on-drag"

example/components/RemoteDataSetExample.tsx

+14-6
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,20 @@ export const RemoteDataSetExample = memo((props: Omit<IAutocompleteDropdownProps
1616
return
1717
}
1818
setLoading(true)
19-
const response = await fetch('https://jsonplaceholder.typicode.com/posts').then(
20-
data =>
21-
new Promise(res => {
22-
setTimeout(() => res(data.json()), 2000) // imitate of a long response
23-
}),
24-
)
19+
const response = await fetch('https://jsonplaceholder.typicode.com/posts')
20+
.then(
21+
data =>
22+
new Promise(res => {
23+
setTimeout(() => res(data.json()), 2000) // imitate of a long response
24+
}),
25+
)
26+
.catch(error => {
27+
console.error('Error fetching data:', error)
28+
throw error
29+
})
30+
.finally(() => {
31+
setLoading(false)
32+
})
2533
const items = (await response) as Record<string, string>[]
2634

2735
const suggestions = items

example/components/RemoteDataSetExample2.tsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { memo, useCallback, useRef, useState } from 'react'
2+
import type { TextInput } from 'react-native'
23
import { Button, Dimensions, Text, View } from 'react-native'
34
import type {
45
IAutocompleteDropdownRef,
@@ -13,7 +14,7 @@ export const RemoteDataSetExample2 = memo((props: Omit<IAutocompleteDropdownProp
1314
const [selectedItem, setSelectedItem] = useState<string | null>(null)
1415
const dropdownController = useRef<IAutocompleteDropdownRef | null>(null)
1516

16-
const searchRef = useRef(null)
17+
const searchRef = useRef<TextInput>(null)
1718

1819
const getSuggestions = useCallback(async (q: string) => {
1920
const filterToken = q.toLowerCase()
@@ -23,7 +24,15 @@ export const RemoteDataSetExample2 = memo((props: Omit<IAutocompleteDropdownProp
2324
return
2425
}
2526
setLoading(true)
27+
console.log('fetching data')
2628
const response = await fetch('https://jsonplaceholder.typicode.com/posts')
29+
.catch(error => {
30+
console.error('Error fetching data:', error)
31+
throw error
32+
})
33+
.finally(() => {
34+
setLoading(false)
35+
})
2736
const items = (await response.json()) as AutocompleteDropdownItem[]
2837
const suggestions = items
2938
.filter(item => item.title?.toLowerCase().includes(filterToken))
@@ -40,7 +49,7 @@ export const RemoteDataSetExample2 = memo((props: Omit<IAutocompleteDropdownProp
4049
}, [])
4150

4251
const onOpenSuggestionsList = useCallback((isOpened: boolean) => {
43-
console.log({ isOpened })
52+
console.log('onOpenSuggestionsList cb', { isOpened })
4453
}, [])
4554

4655
return (

example/components/RemoteDataSetExample3.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ export const RemoteDataSetExample3 = memo(() => {
2020
}
2121
setLoading(true)
2222
const response = await fetch('https://jsonplaceholder.typicode.com/posts')
23+
.catch(error => {
24+
console.error('Error fetching data:', error)
25+
throw error
26+
})
27+
.finally(() => {
28+
setLoading(false)
29+
})
2330
const items = (await response.json()) as AutocompleteDropdownItem[]
2431
const suggestions = items
2532
.filter(item => item.title?.toLowerCase().includes(filterToken))

0 commit comments

Comments
 (0)