Comments (10)
Indeed, in generated app, the core.cljs for android and ios has identical code. But when you start developing your app you will have different UI code for iOS and android. I do not really understand how you can have same code for both platforms.
Maybe you can elaborate what you mean or give an example?
from re-natal.
@drapanjanas Well, I think I've been misled by the name of the file, "core.cljs" .... It's more like a "view.cljs" ;)
But what about very simple UI ? A component like TouchableHighLight would be the same on both android and ios, wouldn't it ?
from re-natal.
Well, I guess, in super simple cases probably one could use only cross platform components. But it is clear that goal of ReactNative is not "write once - run everywhere".
But, I agree that in generated app most of code of core.cljs is definition of view. After all, it is a "hello world" app intended for experimentation with various platform specific components which you can try out right the in core.cljs and see how fighweel reloads your code.
It is left up to developer what other namespaces (shared or platform secific) he/she would like to create to move UI stuff out of core.cljs in a real app.
Have a look at this cross-platform example app I think it is a good and realistic example, which has some shared and platform specific code. Hope this helps.
from re-natal.
Addition to that: http://facebook.github.io/react-native/docs/platform-specific-code.html#content
Definitely it's not a RN goal to "write once - run everywhere", although you can (in runtime) determine the current platform and make some addition changes to the UI, while share the majority of it. And why not - there are plenty cross-platform components already.
I think it depends on a app and developer preferences - it's totally doable to maintain one file and either do the checks in runtime or utilise power of macroses and build two JS output based on compilation settings (e.g. :closure-defines {"app.config.platform" "ios"}
, etc.)
from re-natal.
@artemyarulin thanks for pointing out alternatives! I'm actually open for improvements of current re-natal "hello world" app. Though, I do not have any problems with existing approach having separate core.cljs for iOS and android, so I will not spend time on this.
from re-natal.
I'm not saying that there is any problems with re-natal - it's completely fine and I like it. It's should be up to developer to solve those issue
from re-natal.
Sure Artem, totally agree! Thanks again for involvement and sharing your knowledge! :)
from re-natal.
@drapanjanas @artemyarulin Thank you both for the detailed explanation
from re-natal.
@artemyarulin looks like in current re-natal build setup you actually need to do platform checks at runtime... I have found issue #19 which causes failure in latest luno example app. Maybe you somehow solved this in your ktoa project? My initial (wrong) assumption was that separated iOS and android code so is not even evaluated on wrong platorm.
from re-natal.
Sorry, false alarm, I figured it out. The problem in luno app was caused by requiring platform specific namespace from shared namespace.
from re-natal.
Related Issues (20)
- issue with loading JS files on real device with RN debugger HOT 1
- Choppy pull-to-refresh with `ScrollView` and `FlatList` HOT 1
- Crash on new project - npm install failed. HOT 1
- SOLVED: undefined is not a valid argument for 'in' (evaluating 'StopIteration' in goog.global) HOT 1
- Enabling auto-require breaks re-natal HOT 2
- support shadow-cljs HOT 3
- Android emulator can't load application when debugging is enabled HOT 1
- Incorrect jvm --add-modules options HOT 1
- Is there a way to run a dev environment in the browser ?
- Requiring goog breaks reloading with Namespace already declared
- Use of undeclared Var cljs.user/start-figwheel
- Unable to connect to a component in a module.
- Unknown argument type __attribute__ in method -[RCTUIManager... HOT 1
- Cider-jack-in not working with re-natal. HOT 1
- prn statements not showing on Figwheel
- Feature request: data-url in image source.
- moving to RN 0.6x HOT 3
- Node process figwheel bridge unexpected token error.
- Command failed: lein prod-build HOT 1
- Stuck on Prompt will Show when Figwheel connects to your application.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from re-natal.