https://github.com/derekrsargent/react-native-jsi-example
Using Obj-c over JSI
https://github.com/derekrsargent/react-native-jsi-example
Last synced: 11 months ago
JSON representation
Using Obj-c over JSI
- Host: GitHub
- URL: https://github.com/derekrsargent/react-native-jsi-example
- Owner: derekrsargent
- Created: 2022-07-27T14:56:56.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-11-06T12:14:04.000Z (over 3 years ago)
- Last Synced: 2025-03-04T00:38:17.208Z (over 1 year ago)
- Language: Java
- Size: 328 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# React Native JSI example with Obj-C
Using JSI to bind methods to the JS runtime from a bare react native project.
## Build Requirements and Installation
Follow the typical React Native environment setup and build requirements as per https://reactnative.dev/docs/environment-setup
## Project Setups
See [Tutorial by Oscar Franco](https://ospfranco.com/post/2021/02/24/how-to-create-a-javascript-jsi-module/) for additional information.
The steps followed to create this project:
- Create an empty react native project using `npx react-native init ProjectName`. I wanted to use a bare project instead of using `react-native-turbo-starter`, `react-native-builder-bob` or similiar.
- Add `react-native-jsi-example.h`, `react-native-jsi-example.cpp`, `JSIExample.h`, `JSIExample.mm` files in the ios folder using Xcode.
- Add `JSISampleObject.h`, `JSISampleObject.m` files in the ios folder using Xcode. This is the Objective-C method file (.m instead of .mm since it is pure Objective-C).
- Update `App.js` to invoke the global method and do a console log for this example.
- If JSI binding is unsuccessful try cleaning the build folder using Xcode.
## Other Notes
- The setBridge method is called automatically during app initialization.
## Run Project
Open the `ReactNativeJsi2.xcworkspace` in the `ios` folder using Xcode and press play; or run `yarn ios` in the project root directory.