software-mansion-labs / react-native-turbo-demo

React Native Turbo - an open source library that can bring your turbo-enabled web application into the React Native world.
MIT License
96 stars 12 forks source link

Possible issues while getting this project working #85

Closed krschacht closed 5 months ago

krschacht commented 8 months ago

@pfeiffer Maybe I should open separate issues for these, but while I have your attention let me alert you to a few obstacles I encountered while getting everything working on RN 0.73. Feel free to close this out if it's not helpful:

  1. The published NPM modules you have are out of date with the repo (https://www.npmjs.com/package/react-native-turbo). Usually, I just point directly to the repo but I could not get my package.json file to point directly to the https://github.com/software-mansion-labs/react-native-turbo-demo, I suspect it's because of how it's setup as a mono repo. Ultimately, I had to fork and publish my own so that I could include the latest code from main in my package.json (https://www.npmjs.com/package/krschacht-react-native-turbo).

  2. I kept encountering a build issue and eventually resolved it by reverting "Enable WebView debugging (#77)" in my local branch. I'm no iOS expert but the error was related to isInspectable on this line. I could not figure out how to make XCode happy:

   #if DEBUG
   if #available(iOS 16.4, *) {
     session.webView.isInspectable = true
   }
   #endif
  1. For some of my own code I need access to the VisitableView ref and since this is buried within WebView I had to add a React.forwardRef() around WebView so I could call into the visitableViewRef.current.injectJavaScript(). I'm still learning your code so I don't know if this is a bug/oversight or if I'm doing something odd which is requiring me to access that ref. But flagging for you in case it's helpful.
pfeiffer commented 8 months ago

Hi @krschacht! Thanks for your detailed description :-)

  1. The published NPM modules you have are out of date with the repo.

You're right - we've been holding off publishing new packages as the main branch here is still considered somewhat unstable. In our app, we're using either a local fork or pointing the package.json file to the main branch here using gitpkg, eg:

"react-native-turbo": "https://gitpkg.now.sh/pfeiffer/react-native-turbo-demo/packages/turbo?3cb754b51cb2054dc340b5b5530e3439cb8ed1a8",
  1. I kept encountering a build issue and eventually resolved it by reverting "Enable WebView debugging (https://github.com/software-mansion-labs/react-native-turbo-demo/pull/77)" in my local branch.

I haven't seen any errors related to that - could you share the crash details and iOS and XCode versions?

  1. For some of my own code I need access to the VisitableView ref and since this is buried within WebView I had to add a React.forwardRef() around WebView so I could call into the visitableViewRef.current.injectJavaScript().

The WebView in the Demo folder is supposed to serve as an inspiration, and I think most developers would implement their own and use the exported VisitableView around this. The approach with forwardRef is probably the way to go if you want to inject JavaScript from a consumer of your customized WebView component.

krschacht commented 8 months ago

Thanks @pfeiffer. We can close out this ticket. I have since resolved issue 2, my build issue, by upgrading XCode to 15.x, I was using 14.x.

Would you like contributions to this repo to help improve it? For example, locally I've implemented missing Strada components from the latest version of the Turbo Glitch project. I've decided to invest heavily in Turbo on React Native so I'd love to help you improve this repo and move this project forward, if that is helpful to you.

pfeiffer commented 8 months ago

@krschacht, great, I'll close this then.

Would you like contributions to this repo to help improve it? For example, locally I've implemented missing Strada components from the latest version of the Turbo Glitch project. I've decided to invest heavily in Turbo on React Native so I'd love to help you improve this repo and move this project forward, if that is helpful to you.

Contributions to the repo would be great! The library is still a few PRs from being somewhat stable, as we're working on using it in a 'real' app for the first time and not just as a proof-of-concept we originally did for the Turbo kitchen sink demo.