Skip to content

Instantly share code, notes, and snippets.

Test Your Library against React Native 0.74.0-rcs.

We cut the branch for 0.74 and we released the first RCs. We would like to check that the libraries in the ecosystem are working well, especially with the New Architecture.

To simplify the work, we prepared a sort of template you can use to test your library against the most recent version of React Native. There are two ways to test this:

  1. Using a newly created app;
  2. Using the example app that might live in your library repo.

The first approach can be used to check whether the latest version you already released is compatible with the New Architecture.

import {
SafeAreaView,
View,
StatusBar,
Text,
useColorScheme,
TouchableOpacity,
} from 'react-native';
import {Colors} from 'react-native/Libraries/NewAppScreen';
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
*/
import React, {useState} from 'react';
import {Button, Modal, SafeAreaView, Text, View} from 'react-native';
@cipolleschi
cipolleschi / App.tsx
Created January 31, 2024 15:34
Sample app to test TextInput
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
*/
import React from 'react';
import {
SafeAreaView,
func update(service: String, account: String, type: Int, password: Data) {
let query: [String: Any] = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrService as String: service,
kSecAttrAccount as String: account
kSecValueData as String: password,
kSecAttrType as String: type
]
let status = SecItemUpdate(query as CFDictionary, nil)
import UIKit
import PlaygroundSupport
class MyViewControllerA : UIViewController {
let viewControllerB = MyViewControllerB()
override func loadView() {
print("MyViewControllerA - loadView Invoked")
let view = MyViewA()
view.push = { [unowned self] in
func createQuery(for serivce: String) -> [String: Any] {
let query: [String: Any] = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrService as String: service,
kSecReturnAttributes as String: true,
kSecReturnData as String: true,
kSecMatchLimit as String: kSecMatchLimitAll
]
return query
}
protocol Product {
var price: Decimal { get }
var releaseDate: Date { get }
}
protocol Discountable {
var discount: Double { get }
}
func testPurchasingCoins_success() {
self.app.launchArguments.append(contentsOf: ["-mockPurchase", "true"])
self.app.launch()
let homeView = self.app.otherElements[HomeView.AccessibilityIdentifiers.homeView.rawValue]
XCTAssertTrue(homeView.exists)
self.app.buttons[HomeView.AccessibilityIdentifiers.purchase.rawValue].tap()
XCTAssertEqual(self.app.staticTexts[HomeView.AccessibilityIdentifiers.coins.rawValue].label, "1000")
}
func buildDependencies() -> Dependencies {
#if UITESTING
if UserDefaults.standard.object(forKey: "mockPurchase") != nil {
let mockedMonetizationResult = UserDefaults.standard.bool(forKey: "mockPurchase")
return Dependencies(purchaseManagerDependencies: .mocked(with: mockedMonetizationResult))
}
#endif
return Dependencies()
}