3

I am trying to use a react microfrontend in react-native. To do this, i am trying to serve react app build in local server with react-native-static-server and use it inside web-view. But, i am facing with this problem when i run it for ios;

Undefined symbols for architecture arm64:
  "_RCTRegisterModule", referenced from:
      +[FPStaticServer load] in FPStaticServer.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The build file is copied to root of ios app and here is my react-native code;

import React, {FC, useEffect, useState} from 'react';
import RNFS from 'react-native-fs';
import StaticServer from 'react-native-static-server';
import WebView, {WebViewProps} from 'react-native-webview';

export type TpWebPortalProps = {} & WebViewProps;

const TpWebPortal: FC<TpWebPortalProps> = () => {
  const [source, setSource] = useState('');

  useEffect(() => {
    const path = RNFS.MainBundlePath + '/portals/count';

    const server = new StaticServer(8080, path);
    server.start().then(url => {
      setSource(url);
      console.log('Serving at URL', url);
    });

    return () => {
      server.stop();
    };
  }, []);

  return (
    <WebView
      style={{flex: 1}}
      source={{
        uri: source
      }}
      originWhitelist={['*']}
      javaScriptEnabled
      domStorageEnabled
      allowFileAccess
    />
  );
};

export default TpWebPortal;

0 Answers0