• Complain

it-ebooks - React Native Training

Here you can read online it-ebooks - React Native Training full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2018, publisher: iBooker it-ebooks, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

it-ebooks React Native Training
  • Book:
    React Native Training
  • Author:
  • Publisher:
    iBooker it-ebooks
  • Genre:
  • Year:
    2018
  • Rating:
    3 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 60
    • 1
    • 2
    • 3
    • 4
    • 5

React Native Training: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "React Native Training" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

it-ebooks: author's other books


Who wrote React Native Training? Find out the surname, the name of the author of the book and a list of all author's works by series.

React Native Training — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "React Native Training" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
10.1 shouldComponentUpdate
10.1 shouldComponentUpdate

This chapter can be applied to all react apps.

shouldComponentUpdate

React is usually fast, but you still can improve performance by optimizing function shouldComponentUpdate. By default it returns true, if returns false, the render function will be skipped.

This function is frequently invoked when states or props are changed. So it's important to keep it simple and fast.When you called setState, the render function will always be excuted even if previous states are equal to current. This is where we can make some optimization.

demo1

In demo1, when click button, it will set same state, but render times will still increase.

demo2

In demo2, we check the value of name is equal to before or not, if equal return false, then we reduce the times of render function.

But if our states structure is complicated, such as { a: { b: { c: [1, 2, 3] }}}, we have to compare them deeply. This is obviously against the rules we mentioned above, keep shouldComponentUpdate simple

Immutable-js

Immutable is a concept from functional programming, one of immutable data features is that it can not be modified after being created. So there are some algorithm to create hash for every data structure(for more detail).We can use this feature to prevent deeply compare, shallow compare is enough.Here we will use immutable-js from facebook

demo3

In demo3, we click first button several times, times will only plus one time, click second button , times will increase.

10 Performance (draft)
10 Performance (draft)
1.1 Building an app in 5 minutes
1.1 Building an app in 5 minutes
  1. Requirement follow Getting Started
  2. Generate a new React Native projectreact-native init testRn
  3. Build & run projectreact-native run-iosor open testRn/ios/testRn.xcodeproj and build with XCode's play button

or if the app already builded start the webserver npm startorreact-native - photo 1

or if the app already builded, start the webserver

npm start//orreact-native start
1.2 How it works
1.2 How it works

1.JavaScript bridge

2React Native Packager 13 Debug tools 13 Debug tools 1developer menu - photo 2

2.React Native Packager

13 Debug tools 13 Debug tools 1developer menu 2Chrome Devtools 3log - photo 3

1.3 Debug tools
1.3 Debug tools

1.developer menu

2Chrome Devtools 3log consolelogsome textconsoledira1 b2 - photo 4

2.Chrome Devtools

3log consolelogsome textconsoledira1 b2 c3debuggerbreaking - photo 53.log

console.log('some text');console.dir({a:1, b:2, c:3});debugger;//breaking point

4.Atom & nuclide

5inspect Open Atom Command Palette package with cmd-shift-p and search - photo 6

5.inspect

Open Atom Command Palette package with cmd-shift-p and search "inspector", then click "Nuclide React Native Inspector:Show"

6Real device 61 Deploy to real - photo 7

6Real device 61 Deploy to real - photo 8

6.Real device

6.1 Deploy to real deviceproject_name/ios/project_name/AppDelegate.m

//jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"]; /** * OPTION 2 * Load from pre-bundled file on disk. The static bundle is automatically * generated by the "Bundle React Native code and images" build step when * running the project on an actual device or running the project on the * simulator in the "Release" build configuration. */ jsCodeLocation = [[NSBundle mainBundle] URLForResource:@ "main" withExtension:@ "jsbundle" ];

6.2 Debug in real device

1.project_name/ios/project_name/AppDelegate.m

jsCodeLocation = [NSURL URLWithString:@ "http://172.28.0.230:8081/index.ios.bundle?platform=ios&dev=true" ];

2.node_modules/react-native/Libraries/WebSocket/RCTWebSocketExecutor.m

if (!_url) { NSUserDefaults *standardDefaults = [NSUserDefaults standardUserDefaults]; NSInteger port = [standardDefaults integerForKey:@ "websocket-executor-port" ] ?: 8081 ; NSString *URLString = [NSString stringWithFormat:@ "http://172.28.0.230:%zd/debugger-proxy?role=client" , port]; _url = [RCTConvert NSURL:URLString]; }

14 DOCs APIs 14 DOCs APIs ReactJS React Native Nuclide 15 - photo 9

1.4 DOCs & APIs
1.4 DOCs & APIs
  • ReactJS
  • React Native
  • Nuclide
1.5 Resources
1.5 Resources
  • React Native: Bringing modern web techniques to mobile
  • React Native
  • React Native
  • React Native
  • JavaScriptCore
  • React Native iOS
2.1 Render & JSX
2.1 Render & JSX
.....render() { const txt = 'Hello' ; function say ( name ) { return 'I am ' +name; } return ( < View > < Text > This is a title! </<span class="hljs-class">Text > < Text > {txt} </<span class="hljs-class">Text > < View > < Text > {say('React')} </<span class="hljs-class">Text > </<span class="hljs-class">View > </<span class="hljs-class">View > );}.....
2.3 Lifecyle
2.3 Lifecyle
  1. Instantiation

    1.1 The lifecycle methods that are called the first time an instance is created

    • getDefaultProps
    • getInitialState
    • componentWillMount
    • render
    • componentDidMount

    1.2 For all subsequent uses of that component class:

    • getInitialState
    • componentWillMount
    • render
    • componentDidMount
  2. Lifetime

    • componentWillReceiveProps
    • shouldComponentUpdate // return true|falseshouldComponentUpdate(nextProps, nextState) { return nextProps.id !== this .props.id;}
    • componentWillUpdate //not called for the initial render
    • render
    • componentDidUpdate
  3. Teardown & cleanup

    • componentWillUnmount

24 Props States 24 Props States 1props properties are passed to a - photo 10

2.4 Props & States
2.4 Props & States

1.props: properties are passed to a component and can hold any data

class User extends Component { render(){ const user = this .props.data; this .props.onReady( 'I am ready!' ); return ( < View > < Text > score: {this.props.score} type: {this.props.type} Name: {user.name} Age: {user.age} </<span class="hljs-class">Text > </<span class="hljs-class">View >
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «React Native Training»

Look at similar books to React Native Training. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «React Native Training»

Discussion, reviews of the book React Native Training and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.