Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add React Native Support #45

Open
jho406 opened this issue Apr 15, 2024 · 0 comments
Open

Add React Native Support #45

jho406 opened this issue Apr 15, 2024 · 0 comments
Labels

Comments

@jho406
Copy link
Collaborator

jho406 commented Apr 15, 2024

Today, Rails has Strada, a cordova-ish solution that brings the web to mobile by using web views and a JS bridge to native functionality. Superglue can offer a better alternative. Imagine being able to use standard Rails helpers (the flash, form helpers) and your boring Rails workflow to build React Native applications, all while having 100% Native UI controls and access to react-native libraries.

In other words, while Strada tries to bring the Web to native, Superglue tries to bring just Rails to native.

Thoughts

The movement towards "pages"

expo and other JS frameworks are making their way towards page based development. Since Superglue is about page state over the wire. Is there some compatibility here that is worth investigating?

Known quirks of React Native

ReactNative is not the web. Specifically

  1. ReactNative fetch is NOT the web fetch, and there are known issues with redirects losing cookies
  2. Cookies have more known issues. There is a react-native-cookies package that might help this issue.

Possible solutions:

  1. Polyfill to the webview’s fetch. Its possible to create an instance of the Webview, and using injected javascript, create a polyfill fetch (fork something like https://github.com/developit/unfetch ) that proxys to the Webview.
  2. Embrace the known Quirks. React native isn’t quite the web, so create helpers in superglue_rails that give Rails more superpowers. For example, we can embrace that React has an issue with redirect by never redirecting, instead we can render a payload for the app to navigate to somewhere else.
class PostsController < ApplicationController
  def create
    ... do stuff
    navigate_to_screen :home_screen
  end
end

There might be new helpers to think about, for example: navigate_back. link helpersURL helpers.

Embracing React Native also means that some features of superglue would need to be disabled while on native. For example, UJS helpers. We may also need to reshape the redux state shape to accommodate the new navigation helpers.

Next Steps

Of the solutions, I am leaning towards embracing React Native’s quirks. While I don’t have a thought out comparison, I think that because React Native isn’t quite web, its simpler to embrace to quirkiness then to add a layered solution. I believe that Rails itself can be a “Be productive anywhere” solution, even without the web.

@jho406 jho406 added the triage label Jun 23, 2024
@jho406 jho406 added this to Superglue Jun 24, 2024
@jho406 jho406 moved this to Needs planning in Superglue Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Needs planning
Development

No branches or pull requests

1 participant