Live data from Hacker News

With React Native it’s not all sugar and spice

blog.addjam.com

21–30 of 45 posts

Re: With React Native it’s not all sugar and spice

#21
I'm working on an Android app.

I use react-native solely for the UI which I update, redux-style, with a state-tree. The state and all it's transition and event-handling is done in Kotlin/Java. I've written a small helper that generates kotlin-Interfaces from the react/jsx-files and automatically connects everything.

This way I have react's HotReload and the other benefits for UI-design and a proper typed language and IDE for networking and everything else. Including compile-time checking of events and properties of the UI.

Plus: Kotlin can compile to JavaScript, so if I ever want to port the whole thing to iOS, i just have to switch out a few APIs.

Re: With React Native it’s not all sugar and spice

#22
post #21

I'm working on an Android app. I use react-native solely for the UI which I update, redux-style, with a state-tree. The state and all it's transition and event-handling is done in Kotlin/Java. I've written a small helper that generates kotlin-Interfaces from the react/jsx-files and automatically connects everything. This way I have react's HotReload and the other benefits for UI-design and a proper typed language and…

Just to mention, if you enjoy Kotlin - you might want to try Anvil+Bansa. It is like React+Redux, but for Kotlin (or Java). Resulting APKs are much smaller than React Native and don't rely on jni code.

http://anvil.site/

https://github.com/brianegan/bansa

Re: With React Native it’s not all sugar and spice

#23
post #20

Earlier quoted context omitted.

The case for React is strong in this respect, because Facebook has many lines of React committed to important production code. Your problems are also their problems... unlike Angular, which Google isn't relying on in production code nearly as much.

Yep, React is a good choice because FB is using it in production in their consumer facing apps. But React Native is not used that way by FB (yet?)

FB are using Reactive Native for their Groups, Ad Manager and F8 Conference apps: https://facebook.github.io/react-native/showcase.html

Re: With React Native it’s not all sugar and spice

#25
post #22
post #21

I'm working on an Android app. I use react-native solely for the UI which I update, redux-style, with a state-tree. The state and all it's transition and event-handling is done in Kotlin/Java. I've written a small helper that generates kotlin-Interfaces from the react/jsx-files and automatically connects everything. This way I have react's HotReload and the other benefits for UI-design and a proper typed language and…

Just to mention, if you enjoy Kotlin - you might want to try Anvil+Bansa. It is like React+Redux, but for Kotlin (or Java). Resulting APKs are much smaller than React Native and don't rely on jni code. http://anvil.site/ https://github.com/brianegan/bansa

I've thought about Anvil, but I like React and I can reuse stuff from my web-development. Like tachyons styling [0].

Regarding bansa: Sounds nice, but I've never seen the benefit of using a library for state and state-reduction. You can implement and customise for yourself in less than 50 lines. (I don't use the redux library on the web either)

The only thing I would like is being able to reuse data-structures of react-native, so they won't get serialized all the time.

Thanks for the tips, though!

[0] https://github.com/fab1an/react-native-tachyons

Re: With React Native it’s not all sugar and spice

#26
post #20

Earlier quoted context omitted.

The case for React is strong in this respect, because Facebook has many lines of React committed to important production code. Your problems are also their problems... unlike Angular, which Google isn't relying on in production code nearly as much.

Yep, React is a good choice because FB is using it in production in their consumer facing apps. But React Native is not used that way by FB (yet?)

[deleted]

Re: With React Native it’s not all sugar and spice

#27

> With each framework or platform we develop with we need to adapt to the conventions. From back end work using frameworks like Rails and Elixir to native mobile projects each has it’s own way to hang together a project. Some have their own way to hang together a project. Much of the React ecosystem is not so opinionated. A lot of JavaScript out there exists in codebases in a variety of languages and frameworks—Rails…

React is not a framework. It's just a templating library with a preprocessing step (JSX) and a diffing algorithm that efficiently renders to the DOM.

Re: With React Native it’s not all sugar and spice

#28
HN community, how would I make my core model + business logic cross-platform? I want to re-use the model and its behavior (like some data evaluators) in my Web app, on Android and iOS without rewriting it every time from scratch. I'm fine with creating native code for the UI. but I'd like to share at least some code. What would you recommend?

Re: With React Native it’s not all sugar and spice

#29
I don't mind switching between different contexts, I frequent the terminal for git an other stuff anyway. I think it is fairly magic that one may finally develop the same code for both iOS and Android. Huge productivity win, especially using Clojurescript!

I agree with the instability though, nothing for someone afraid of rumbling around in the RN source code to solve things like this https://github.com/facebook/react-native/issues/7720

Re: With React Native it’s not all sugar and spice

#30
post #28

HN community, how would I make my core model + business logic cross-platform? I want to re-use the model and its behavior (like some data evaluators) in my Web app, on Android and iOS without rewriting it every time from scratch. I'm fine with creating native code for the UI. but I'd like to share at least some code. What would you recommend?

If you use react native on mobile and react on the web the core model and business logic can easily be shared since it is just pure js. And you can use any of the languages that transpiles to js: TypeScript, Clojurescript etc.
Post reply on HN