react-native/packages/rn-tester
Mateo Guzmán 32931466ed feat(text-input): [iOS] inputAccessoryViewButtonLabel prop (#47441)
Summary:
Fixes https://github.com/facebook/react-native/issues/29244, also mentioned in https://github.com/facebook/react-native/issues/25009

As mentioned in the linked issues, the current return key label in the input accessory view is not localized. In the code, right now the texts are hardcoded (see: [RCTTextInputComponentView.mm](https://github.com/facebook/react-native/blob/main/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm#L552) and [RCTBaseTextInputView.mm](https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm#L694)). I could not find the historical reason for this, but doing some investigation there doesn't seem to be a way of getting the translated text into the code by using the existing props. (Ref: https://stackoverflow.com/a/58190342/5415299)

The solution: adding a new property `inputAccessoryViewButtonLabel` which can be used to overwrite these defaults non-translated values. The property is optional to avoid breaking changes.

The implementation works for both Fabric and Paper.

## Changelog:

[IOS] [ADDED] - TextInput `inputAccessoryViewButtonLabel` prop

Pull Request resolved: https://github.com/facebook/react-native/pull/47441

Test Plan:
A new example has been added under the `TextInput` examples in the RNTester. See below:

<details>
<summary>Video demonstrating how the new prop behaves</summary>

https://github.com/user-attachments/assets/b15cb8b8-494a-4f41-b434-e33eeef5d267

</details>

Reviewed By: cipolleschi

Differential Revision: D65533493

Pulled By: javache

fbshipit-source-id: d80bf501ba3e38bf3b09833170780df45a26bb61
2024-11-13 06:44:23 -08:00
..
.maestro add e2e test for empty case in flatlist (#47444) 2024-11-06 04:07:01 -08:00
android/app Bump Kotlin 1.9.x to 2.0.x (#46955) 2024-10-11 05:34:02 -07:00
IntegrationTests Enable lint/sort-imports everywhere (#41334) 2023-11-06 12:59:38 -08:00
js feat(text-input): [iOS] inputAccessoryViewButtonLabel prop (#47441) 2024-11-13 06:44:23 -08:00
NativeComponentExample Add test case for set opacity in new arch examples (#47043) 2024-10-16 08:33:37 -07:00
NativeCxxModuleExample Add C++ Turbo Module enum Event Emitter example (#46049) 2024-08-19 08:26:20 -07:00
NativeModuleExample fix: set proper framework dependencies for built-in pods (#45104) 2024-06-24 03:14:55 -07:00
RCTTest Factor out the CXX language standard in a separate const (#45374) 2024-07-11 05:25:38 -07:00
RNTester Generate RCTThirdPartyComponentProvider (#47518) 2024-11-12 07:38:03 -08:00
RNTesterIntegrationTests Remove deprecated Snapshot tests (#39720) 2023-10-03 04:33:53 -07:00
RNTesterPods.xcodeproj Fixes rn-tester bundled images examples (#44482) 2024-11-12 04:18:17 -08:00
RNTesterPods.xcworkspace
RNTesterUnitTests fix(iOS): small test fix for RCTViewTests (#47314) 2024-10-31 16:24:41 -07:00
scripts Prepare scripts to simplify E2E testing (#46545) 2024-09-20 03:29:43 -07:00
.babelrc Move react-native-babel-transformer and react-native-babel-preset from Metro to React Native repo (#38228) 2023-07-27 11:48:16 -07:00
.eslintrc
.gitignore add .gitignore for rn-tester build artifacts (#44041) 2024-04-11 04:53:08 -07:00
.xcode.env feat(ios): allow for custom project dir in react-native-xcode script (#35449) 2022-12-02 04:09:48 -08:00
Gemfile Pin Xcodeproj to < 1.26.0 (#47237) 2024-10-28 04:20:31 -07:00
metro.config.js Add react-native-test-library package (#43068) 2024-04-09 11:35:43 -07:00
package.json Let lib maintainer be explicit with componentProvider mapping (#47520) 2024-11-12 07:38:03 -08:00
Podfile Add react-native-test-library package (#43068) 2024-04-09 11:35:43 -07:00
Podfile.lock bump Folly to 2024.10.14.00 (#47033) 2024-10-24 10:10:19 -07:00
PrivacyInfo.xcprivacy add privacy manifest to pod install 2024-04-02 21:38:52 -07:00
react-native.config.js Revert D59170923 (#45447) 2024-07-15 13:44:09 -07:00
README.md docs(rn-tester): adding extra instructions to disable fabric (#47127) 2024-10-21 09:18:25 -07:00

RNTester

The RNTester showcases React Native views and modules.

Running this app

Before running the app, make sure you ran:

git clone https://github.com/facebook/react-native.git
cd react-native
yarn install

Running on iOS

If you are testing non-fabric component, search for and modify the fabric_enabled flag in RNTester's Podfile.

fabric_enabled = false

Also, if you previously built RNTester with fabric enabled, you might need to clean up the build files and Pods.

# Clean the generated files and folders to clean install RNTester
cd packages/rn-tester
yarn clean-ios

If you are still having a problem after doing the clean up (which can happen if you have built RNTester with older React Native versions where files were generated inside the react-native folder.), the best way might be to clean-install react-native (e.g. remove node_modules and yarn install). If after cleaning up, you are still having issues, you might also want to try RCT_NEW_ARCH_ENABLED=0 bundle exec pod install to disable the new architecture as it might be conflicting.

Both macOS and Xcode are required.

  1. cd packages/rn-tester
  2. Install Bundler: gem install bundler. We use bundler to install the right version of CocoaPods locally.
  3. Install Bundler and CocoaPods dependencies: bundle install && bundle exec pod install or yarn setup-ios-hermes. In order to use JSC instead of Hermes engine, run: USE_HERMES=0 bundle exec pod install or yarn setup-ios-jsc instead.
  4. Open the generated RNTesterPods.xcworkspace. This is not checked in, as it is generated by CocoaPods. Do not open RNTesterPods.xcodeproj directly.

Note for Apple Silicon users

If you own a Mac laptop with Apple Silicon, you need to run some different commands to install and run cocoapods.

  • sudo arch -x86_64 gem install ffi: this installs the ffi package to load dynamically-linked libraries.
  • arch -x86_64 pod install: this run pod install with the right architecture.

Running on Android

You'll need to have all the prerequisites (SDK, NDK) for Building React Native installed.

You can build and run RN-Tester by using this command from the root of the repo:

yarn android

If you wish to use JSC instead you should invoke:

cd packages/rn-tester
yarn install-android-jsc
yarn start

Note

Building for the first time can take a while.

If you're using a physical device, run adb reverse tcp:8081 tcp:8081 to make sure the device can access Metro.

See Running on Device for additional instructions on using a physical device.

Building from source

Building the app on both iOS and Android means building the React Native framework from source. This way you're running the latest native and JS code the way you see it in your clone of the github repo.

This is different from apps created using react-native init which have a dependency on a specific version of React Native JS and native code, declared in a package.json file (and build.gradle for Android apps).