Earlier quoted context omitted.
Please, please have constraint-based layout support- I know you want to have it, given your work on react-gss :-)
Given the presence of https://github.com/facebook/css-layout it will probably flex-based. Not cool as a constraint based layout but good enough for easier portability of knowledge.
Use ReactJS to Build Native Apps
91–100 of 175 posts
Re: Use ReactJS to Build Native Apps
#92Hi, I'm just reading through the ReactJS docs for the first time, and I found something peculiar. Let me explain. So, as I understand ReactJS invokes a render() method defined by the user (programmer), and the result of that is diff'ed to previous results of the same method, and as a result, the DOM is modified. I can understand this, but... The DOM is already incrementally rendered by the browser. That is, changes t…
The browser tries to batch updates as efficiently as possible, but because of the model there are limits on that, reflow and layout thrashing are easy pitfalls to fall into for instance. React's model obviates these issues so the system can make significantly more assumptions about what is happening, and it can combine and batch more aggressively.
Furthermore, React's updates can trivially be delayed as much as necessary (in browsers, usually to sync them with the next repaint using requestAnimationFrame), not so for DOM mutations.
> Also, the render() method itself could be quite big and thus could take a long time to run, and almost completely nullify all advantages of incrementally updating only the display.
It could be but it usually isn't, and more importantly for these cases (and others) the system can be told that there's no need to re-render the component (`shouldComponentUpdate` in react), the previous result can be reused as-is.
For "pure" components (which simply map application state to render state) it's easy to implement, and downright trivial when using persistent datastructures: it's just an identity check (which is why systems built from the ground up on persistent datastructures like clojurescript/om or elm.html are faster than "naïve" react OOTB: they can assume components are pure, will only use their parameters/state to generate UI state, and that said parameters/state hasn't been screwed with; React being a more general-purpose JS library can't afford to make these assumption, it has to be opted in explicitly)
Re: Use ReactJS to Build Native Apps
#93Earlier quoted context omitted.
Given the presence of https://github.com/facebook/css-layout it will probably flex-based. Not cool as a constraint based layout but good enough for easier portability of knowledge.
Can I create the largest possible square div in a rectangular div with this library? That is my standard test as to whether a layout framework is advanced enough to meet my basic needs. (vanilla CSS fails this test of course, even with the most recent extensions, AFAIK)
Re: Use ReactJS to Build Native Apps
#94Earlier quoted context omitted.
Currently working on something similar (minus browserify) -- I don't think React should try to get into the doing-everything game. That said, their success (over something like node-webkit + react) will definitely depend on how well they match and integrate the native APIs.
Doing everything is a side effect of the architecture. "The virtual dom is an implementation detail of React.js. React Native demonstrates that many rendering contexts are possible." This was kind of the exciting point all along :). DOM just happens to be the output of a function that people are most interested in at the moment. but people have been talking about using it with canvas and other stuff, too. It's a gene…
Re: Use ReactJS to Build Native Apps
#95As someone who is just getting into iOS dev is there any benefit (that's at least known at this point) to using React over Swift for UI?
If you already know ReactJS, then it'll probably be a lot easier for you to learn React Native than Swift or Objective-C.
If you are working on a team with primarily JS developers, React Native is probably a better choice to go with.
Will this cause Swift to be irrelevant? Probably not.
--
If you are learning iOS and doing production / client work, you should be aware that using a third party framework could actually break your app. I'm interested in React Naive, but also very weary about it. Facebook released a framework called Three20 back in iOS 2.0/3.0 days and abandoned the project shortly afterwards. Of course being open source there is bound to be people who take over the project, but it's something to think about.
Re: Use ReactJS to Build Native Apps
#96Hi, I'm just reading through the ReactJS docs for the first time, and I found something peculiar. Let me explain. So, as I understand ReactJS invokes a render() method defined by the user (programmer), and the result of that is diff'ed to previous results of the same method, and as a result, the DOM is modified. I can understand this, but... The DOM is already incrementally rendered by the browser. That is, changes t…
There are added benefits for an immutable / FRP style of building a UI, but I think you're more interested in the rest of my answer. Nothing to be confused about, you have a valid hypothesis: "Rendering and Diffing in Javascript is slower than DOM manipulation". However, all hypothesis need to be experimented before having any real meaning. It just happens that testing this hypothesis and finding it invalid was the f…
Now for a certain value of N, things will become slow, unresponsive. I'm guessing now that this value of N is above the value where the browser cannot handle this number of elements anyway. Is this correct?
PS: I understand that it is possible to completely optimize the listbox case. But that is not the scenario I'm interested in. I'm interested most and above all in the typical use-case. I'm just using a listbox as an example here. Just replace it by any other sufficiently complicated and customized UI component if desired.
Re: Use ReactJS to Build Native Apps
#97Hi, I'm Jordan from the React team. I'm happy to answer any questions about React Native, but @vjeux will be giving a more thorough talk tomorrow that you won't want to miss (if you're at ReactJSConf), so I might wait for him to answer some of them. This is not the DOM. This is not a web view. If you know ReactJS, you can build native apps with React Native.
There will be more detail tomorrow, but at a high level: * JS engine on a background thread * Communicates via batched, async messaging protocol to a native (objc or android) server running on the main thread (basically create_view(), update_view(), destroy_view(), on_event() etc) * Plug-in for React that speaks that protocol * Tools to make cross-platform dev a bit easier (standard text component, cross-platform fle…
Re: Use ReactJS to Build Native Apps
#98## Architecture
Both Titanium SDK and this Native React thing do have a JavaScript runtime behind the curtains.
Both frameworks will run the JS runtime on the background, on a different thread from the UI. This is incredibly important to remind.
Titanium SDK follows an OOP-ish, imperative approach. You create views using factories (`Titanium.UI.createScrollView({ })`) and you add those views to parent views (`parent.add(child)`). This is very similar to a browser DOM, and in fact it’s cumbersome to work with. They built an xml preprocessor called Alloy which does a better job at exposing the view hierarchy right in the source, but it just compiles down to JS, `create()` and `add()`.
This is important for the evaluation at least for the following reason: every time you update a property on a view (actually on a proxy object to the real view) you’re crossing the bridge and you have to pay that penality. The bridge is the void between the JS runtime’s thread and the main, UI’s one. This is incredibly painful when trying to do JS animations, sometimes if you’re not careful you can get hurt very badly. You can still do great things, but it’s way better to use the native `.animate()` methods, which cross the bridge only twice (at start, and at the end as a callback invoking).
On Native React you should not have this kind of problems because changes will be batched and updated on a update loop basis or at least debounced. Or at least optimized in some smart way. I believe.
## Layout
One big problem will be the layout. Given that they don’t want the developers to understand every layout system every platform provides, they have to normalize it somehow. Titanium SDK has it’s own layout system, incredibly easy to understand even from a web-only dev experience:
a) by default everything is absolute positioned,
b) you can get a vertical flow layout by setting the 'layout' property on the parent view or
c) you can get a horizontal flow (inline-block-ish) by setting 'layout' to horizontal.
Native React will probably follow a more intimately web-ish approach, just look at this JS/C/Java implementation of the box-model and flex-box specification by Facebook itself [1]
[1]: https://github.com/facebook/css-layout
## Support and limits
Titanium SDK is always criticized for being to limited in what you can do with it. This actually comes from two different issues:
1) they have to (almost) manually implement every API you might need, by proxying from native-land to JS-land;
2) they have to follow every release of the platform’s SDK;
3) you cannot just put native code along-side your JS code, so you cannot go where they didn’t.
Let’s see how Native React will solve this issue.
Titanium SDK is undergoing an heavy lifting refactoring to solve exactly this issues. The project is code-named Hyperloop and is already working behind the curtains for the Windows 8 version of the SDK.
## Conclusion
Because I shamelessy want to karma-drift this topic, I’ll stop here.
It’s interesting, but until they show us some (native) code... it’s just ideas.
Follow me on twitter (@_pier) and github (@yuchi) for Titanium related stuff.
Also my company, SMC, does a lot of great opensource things for Titanium (on gh we’re @smclab)