12-hour Package you learn Reactnativeapp development based on the Reactmix Framework (a) Hello world!

Source: Internet
Author: User

Reactmixhttps://github.com/xueduany/react-mix since the release yesterday, got a lot of small partners of the hot, very happy to help everyone to solve the problem of holding in the heart for a long time "if I will only Html,css,jquery", I don't have to study, what is MVVM? Will it be reactnative? The answer is no problem, as long as you get through our Reactmix framework, you can start an app development work within 12 hours. Let's try it.

First of all, the foundation of the Reactmix is based on the reactnative to achieve a layer of grammatical sugar, to help everyone easy and convenient implementation of a code-take-all H5,pc,ios, Android, Winphone Dream, then we contact the most H5 development examples, First of all, we need to know what we are drawing pages on?

Yes, based on HTML, what are the most common elements in HTML?

Answer: Box model

Divided into block elements, inline elements, fast elements good understanding, that is, Div, inline elements, usually text node elements, such as span

There are also form elements, such as the input box input,select drop-down box, Button element

Basically with these, we can prop up a page of HTML, right.

In Reactmix, we also provide these elements, the only difference is that the first letter is uppercase, such as Div,span,input,select,button, why the first letter to capitalize it? Because there are no HTML elements in reactnative First, these elements are near-custom components of our encapsulation, and in the REACTJS specification, the non-system-provided components must be capitalized, differentiated, But the usage and attributes are the same as the elements we use in HTML.

Ok, then the second learning Point, Reactnative is based on the JSX syntax to implement the template, what is called JSX? I believe that the students who have used Reactjs should have heard

Similar to this, this is the JSX syntax, very much want to write HTML, is the value of the property, equal to the number behind if it is an object, based on {} curly braces to hold up, can be written JS code

Students see the image of grammar are es6+ grammar, there are many new JS features of the syntax of sugar, many people may ask, if so, then the old version of the browser support it? The answer is yes, because our reactmix has a synchronous translation mechanism that can translate the code of these new grammar styles into ES5 code, ensuring that the old version of the browser can run normally. It also supports dynamic debugging of the new syntax, just like this

Based on Webpack and Sourcemap, we can still easily debug the JS code of ES6 syntax.

Ok, first we need to checkout code Https://github.com/xueduany/react-mix from GitHub, (preferably Mac system, all bash scripts are currently written based on Mac system)

Then execute install.sh, the main function is to perform NPM install at the Reactmix project root, and to perform NPM install in the reactmix/reactnative subdirectory

Why is there a separate reactnative subdirectory here?

This is because the Reactnative project defaults to CSS style files, so we put the CSS directory in the reactnative directory layer, Synchronous translation of CSS to the reactnative directory via the automated compilation tool React.css.build.js

In addition to the H5 code is also the same, this part of the code in the Reactmix/web directory, because the UI component this piece is to save the package script, it is not through the if else logic to differentiate, but directly split into the same name of the two different implementations of the file, Placed in the Reactnative directory and web directory, to make it easy to differentiate between H5 use or app use, but interface consistency

OK,NPM Install finished, we open reactmix/reactnative/ios/native.xcodeproj, open the Xcode interface, click Run

You can see our beautiful sui he sister directly in the simulator.

Let's write the first Hello World page.

We open reactmix/reactnative/index.js.

Clear all the code and enter the following REACTJS code

First, define a static class of inheritance and base class app called HelloWorld

Class Helloword extends app{

}

Then write a render method, return a jsx text Helloword, and add the style

Finally we execute the static method of this class run () and see the effect

done! congratulation!

Then we execute the reactmix root directory webpack synchronous compilation, Webpack–w–d

In the browser open reactmix/web/index.html, you can sync to see the corresponding code H5 synchronous translation over the version, how, isn't it amazing? The first HelloWorld has been completed for a total of no more than 1 hours ~ ^_^

12-hour Package you learn Reactnativeapp development based on the Reactmix Framework (a) Hello world!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.