Currently, I am following the React Native guide to incorporate a React Native view into an iOS application.
import React from 'react';
{ AppRegistry, View, Text } from 'react-native';
const TestView = () => {
return (
<View>
<Text>Hello World</Text>
</View>
);
};
AppRegistry.registerComponent('TestView', () => TestView);
As per the documentation, I am creating the view within the iOS app using the suggested method:
guard let jsCodeLocation = URL(string: "http://localhost:8081/index.bundle?platform=ios") else { return }
let rootView = RCTRootView(
bundleURL: jsCodeLocation,
moduleName: "TestView",
initialProperties: nil,
launchOptions: nil
)
let vc = UIViewController()
vc.view = rootView
self.present(vc, animated: true, completion: nil)
However, upon presenting the view controller, it appears blank:
The integration of React Native in the project is accurate. Even though index.js
is triggered when the view controller is presented, it remains ineffective. Any thoughts or suggestions?
https://i.sstatic.net/P4JVb.png
Xcode recordings:
[native] Running application TestView ({ initialProps = { }; rootTag = 51; })
[connection] nw_socket_handle_socket_event [C15:1] Socket SO_ERROR [61: Connection refused]