Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork22
Description
Today, Rails hasStrada, acordova-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
- ReactNative fetch is NOT the web fetch, and there are known issues withredirects losing cookies
- Cookies havemore known issues. There is areact-native-cookies package that might help this issue.
Possible solutions:
- Polyfill to the webview’s fetch. Its possible to create an instance of the Webview, and usinginjected javascript, create a polyfill fetch (fork something likehttps://github.com/developit/unfetch ) that proxys to the Webview.
- Embrace the known Quirks. React native isn’t quite the web, so create helpers in
superglue_railsthat 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 endend
There might be new helpers to think about, for example:navigate_back. linkhelpersURL helpers.
Embracing React Native also means that some features of superglue would need to be disabled while on native. For example, UJShelpers. We may also need to reshape theredux 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.