# React Native Tutorial: Building Apps with JavaScript

**URL:** <https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106>\
**Category:** 🎓 Courses & Articles\
**Created:** [April 4, 2016, 3:00pm UTC](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106 "2016-04-04T15:00:56Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![chadrahder](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/chadrahder/32/33319_2.png) [@chadrahder](https://forums.kodeco.com/u/chadrahder)\
**Post date:** [May 27, 2016, 8:39am UTC](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106/22 "2016-05-27T08:39:59Z")

</div>

Unfortunately I’m having problems just with the Hello World app. Here’s the code for it so far:

```auto
'use strict';

var React = require('react-native');
var styles = React.StyleSheet.create({
		text:
		{
			color: 'black',
			backgroundColor: 'white',
			fontSize: 30,
			margin: 80
		}
	});

class PropertyFinderApp extends React.Component {
	render() {
		return React.createElement(React.Text, {style: styles.text}, "Hello World!");
	}
}

React.AppRegistry.registerComponent('PropertyFinder', function()
{
	return PropertyFinderApp;
});

```

And here’s the log from XCode:

```nohighlight
2016-05-27 09:37:33.189 [fatal][tid:com.facebook.react.RCTExceptionsManagerQueue] Unhandled JS Exception: Super expression must either be null or a function, not undefined
2016-05-27 09:37:33.214 [error][tid:com.facebook.react.JavaScript] Module AppRegistry is not a registered callable module.
2016-05-27 09:37:33.215 [fatal][tid:com.facebook.react.RCTExceptionsManagerQueue] Unhandled JS Exception: Module AppRegistry is not a registered callable module.

```

---

<div class="post-metadata">

**Author:** ![miktav](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/miktav/32/81494_2.png) [@miktav](https://forums.kodeco.com/u/miktav)\
**Post date:** [May 28, 2016, 2:18am UTC](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106/23 "2016-05-28T02:18:08Z")

</div>

I had the same problem. Something like this is what worked for me.

Replace this line:  
var React = require(‘react-native’);

With this:  
import React, { Component } from ‘react’;  
import {  
AppRegistry,  
StyleSheet,  
Text  
} from ‘react-native’;

Removed ‘React.’ prefix everywhere.

For example, instead of React.AppRegistry, just use AppRegistry.

---

<div class="post-metadata">

**Author:** ![miktav](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/miktav/32/81494_2.png) [@miktav](https://forums.kodeco.com/u/miktav)\
**Post date:** [May 28, 2016, 2:20am UTC](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106/24 "2016-05-28T02:20:40Z")

</div>

I used the “latitude” property.

---

<div class="post-metadata">

**Author:** ![saroshmirza](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/saroshmirza/32/88050_2.png) [@saroshmirza](https://forums.kodeco.com/u/saroshmirza)\
**Post date:** [May 28, 2016, 4:11pm UTC](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106/25 "2016-05-28T16:11:08Z")

</div>

Hi Chadrahder,

Replace it with the following code:

import React, { Component } from ‘react’;  
import {  
AppRegistry,  
StyleSheet,  
Text,  
View,  
NavigatorIOS  
} from ‘react-native’;

var styles = StyleSheet.create({  
text:  
{  
color: ‘black’,  
backgroundColor: ‘white’,  
fontSize: 30,  
margin: 80  
}  
});

class PropertyFinderApp extends Component {  
render() {  
return “Hello World”  
}  
}

AppRegistry.registerComponent(‘PropertyFinder’, function()  
{  
return PropertyFinderApp;  
});

---

<div class="post-metadata">

**Author:** ![miktav](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/miktav/32/81494_2.png) [@miktav](https://forums.kodeco.com/u/miktav)\
**Post date:** [May 28, 2016, 9:39pm UTC](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106/26 "2016-05-28T21:39:47Z")

</div>

If you are having problems with searching by location, try toggling the location in the Simulator:

1. Select Debug \> Location \> None
2. Select Debug \> Location \> Custom Location…
3. Enter coordinates and click OK.  
This resolved the issue for me.

---

<div class="post-metadata">

**Author:** ![chadrahder](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/chadrahder/32/33319_2.png) [@chadrahder](https://forums.kodeco.com/u/chadrahder)\
**Post date:** [May 29, 2016, 2:23pm UTC](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106/27 "2016-05-29T14:23:44Z")

</div>

Thank you to everyone who answered my question. That certainly got things going. This is a great tutorial @tomelliott it would be great to see it updated because IMO it is invaluable – great work 🙂

It seems as though some people have noticed that when you press to view a second property after you have already viewed another one, the first one you viewed is loaded instead of the one you pressed.

As has been pointed out elsewhere this is because the API no longer seems to return a `guid` field for each record.

The other key we can use then is `rowID`.

I’m not sure I fully understand what the `rowHasChanged` function is doing and I can’t see it being called, but a good way to compare these is as follows:

```auto
var dataSource = new ListView.DataSource({
    rowHasChanged: (r1, r2) => this.props.listings.indexOf(r1) !== this.props.listings.indexOf(r2)
});

```

This should get the index of each row from the listings prop.

So far so good… `renderRow` already has a `rowID` for each row so we can pass that into our `onPress` method:

```auto
onPress={() => this.rowPressed(rowID)}

```

And the `rowPressed` method itself just becomes:

```auto
rowPressed(rowID)
{
	var property = this.props.listings[rowID];

	...
}

```

This works for me 🙂

Hope it helps!

---

<div class="post-metadata">

**Author:** ![chadrahder](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/chadrahder/32/33319_2.png) [@chadrahder](https://forums.kodeco.com/u/chadrahder)\
**Post date:** [May 30, 2016, 2:09pm UTC](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106/28 "2016-05-30T14:09:53Z")

</div>

Anyone got any tips for porting the same project to Android? Specifically it would need to use Navigator instead of NavigatorIOS and aside from the loading indicator (which is simple) there’s not much else therefore it should be simple but Navigator seems slightly complicated.

I’ve got it working so the SearchPage component loads but when I click Go I get an error related to this.props.navigator.

---

<div class="post-metadata">

**Author:** ![alna](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/alna/32/33338_2.png) [@alna](https://forums.kodeco.com/u/alna)\
**Post date:** [May 30, 2016, 4:42pm UTC](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106/29 "2016-05-30T16:42:10Z")

</div>

Great stuff, and it all works!  
(with minor changes for react-native 0.27.0-rc2)

As people already suggested namespaces have changed for ‘react’ and ‘react-native’. I like Tom’s approach require(‘…’) so my fix in index.ios.js is like this:

> ‘use strict’;  
> var React = require(‘react’);  
> var ReactNative = require(‘react-native’);

You’ll need to figure out after that which components is in which namespace. However the following destructive syntax taken from my modified SearchResult.js can help:

> ‘use strict’;  
> var React = require(‘react’);  
> var {  
> Component  
> } = React;

> var ReactNative = require(‘react-native’);  
> var {  
> StyleSheet,  
> Text,  
> View,  
> TouchableHighlight,  
> Image,  
> ListView  
> } = ReactNative;

And lastly the guid property is no longer supported by the Nestoria api (or at least i didn’t see it 🙂) , but you can use _thumb\_url_ for the uniqueness purpose. So you’ll need to replace **ALL** occurrences of _guid_ with _thumb\_url_ in SearchResults.js, e.g. replace:

> var property = this.props.listings.filter(prop =\> prop.guid === guid)[0];

with:

> var property = this.props.listings.filter(prop =\> prop.thumb\_url === thumbUrl)[0];

Thank you for the great tutorial!  
Tom, great references as well, which is extremely useful!!

---

<div class="post-metadata">

**Author:** ![chadrahder](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/chadrahder/32/33319_2.png) [@chadrahder](https://forums.kodeco.com/u/chadrahder)\
**Post date:** [May 30, 2016, 5:45pm UTC](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106/30 "2016-05-30T17:45:09Z")

</div>

This is very useful, thanks.

Do you think there are any problems with the approach I recommended which uses the index within the property list array?

---

<div class="post-metadata">

**Author:** ![alna](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/alna/32/33338_2.png) [@alna](https://forums.kodeco.com/u/alna)\
**Post date:** [May 30, 2016, 6:53pm UTC](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106/31 "2016-05-30T18:53:37Z")

</div>

Not really, it will work as well. However you are bound to the row index which may change if some sorting/filtering is applied to the list. You can fix that by reindexing after such operation is applied. Binding to unique data property have more chances to succeed - however if they change the API again it will fail too 😉, so nothing is perfect!

---

<div class="post-metadata">

**Author:** ![chadrahder](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/chadrahder/32/33319_2.png) [@chadrahder](https://forums.kodeco.com/u/chadrahder)\
**Post date:** [May 30, 2016, 7:26pm UTC](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106/32 "2016-05-30T19:26:26Z")

</div>

Great point, thank you.

I considered seeing if it was possible to generate a hash of a object and use that, but it didn’t seem straight forward. I think your solution, all things considered is better.

Someone above recommended the latitude property, but I think this is potentially not ideal in case there are several entries that might have the same latitude for some reason.

---

<div class="post-metadata">

**Author:** ![neil](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/neil/32/34170_2.png) [@neil](https://forums.kodeco.com/u/neil)\
**Post date:** [June 12, 2016, 10:55am UTC](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106/33 "2016-06-12T10:55:53Z")

</div>

Great tutorial. I can confirm the issues (and fixes) regarding GUID. One thing, which is not working well is the behavior of the app on change of orientation. In landscape things are not rendered correctly.

---

<div class="post-metadata">

**Author:** ![ahliu1](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/ahliu1/32/33243_2.png) [@ahliu1](https://forums.kodeco.com/u/ahliu1)\
**Post date:** [June 15, 2016, 6:52am UTC](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106/34 "2016-06-15T06:52:33Z")

</div>

I tried doing the tutorial with my best abilities since I’m really new to React Native (or React development in general) and I was wondering if anyone else is having a problem with the information when going into property view? It seems like its only generating the first data when going to any of the property list.

How do I pass the information from this **SearchResults.js**

```
  constructor(props) {
    super(props);
    var dataSource = new ListView.DataSource(
      {rowHasChanged: (r1, r2) => r1.guid !== r2.guid});
    this.state = {
      dataSource: dataSource.cloneWithRows(this.props.listings)
    };
  }

```

into **PropertyView.js**

 ![](https://raywenderlich-com-v3-forums.s3.amazonaws.com/original/3X/5/6/56d65a1203c26d68b3bb46a01acad2ab3089b0e6.png)

---

<div class="post-metadata">

**Author:** ![snowcrash](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/snowcrash/32/34619_2.png) [@snowcrash](https://forums.kodeco.com/u/snowcrash)\
**Post date:** [June 17, 2016, 9:50am UTC](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106/35 "2016-06-17T09:50:37Z")

</div>

On the initial build, i.e. after running this line:

react-native init PropertyFinder

I get the white PropertyFinder screen. However, a few seconds later it refreshes and I get a red screen with the following errors:

Unable to execute JS call: \_\_fbBatchedBridge is undefined

Has something changed? All I’m doing is creating a bare bones project and running it.

---

<div class="post-metadata">

**Author:** ![doe](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/doe/32/34924_2.png) [@doe](https://forums.kodeco.com/u/doe)\
**Post date:** [June 21, 2016, 4:11pm UTC](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106/36 "2016-06-21T16:11:09Z")

</div>

I’m not very well in english, perhaps that’s why I can’t understand what does this part means: “UI is simply expressed as a function of the current application state”. Could you give some more words on that?  
Isn’t any UI is the function of the current applications state? It’s not the picture after all. If so, then it’s not the advantage.

---

<div class="post-metadata">

**Author:** ![mttmanzo](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/mttmanzo/32/35790_2.png) [@mttmanzo](https://forums.kodeco.com/u/mttmanzo)\
**Post date:** [June 29, 2016, 9:20am UTC](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106/37 "2016-06-29T09:20:21Z")

</div>

Hi ahliu1, I had the same problem and I realised that ‘guid’ is not present on the response json. My fix was to use ‘title’ instead to check which row you pressed:

Inside the _renderRow_ method in **SearchResults.js** replace guid with title:

`return ( <TouchableHighlight onPress={() => this.rowPressed(rowData.title)} `  
and inside the filter method of _rowPressed_ too:

`rowPressed(propertyTitle) { var property = this.props.listings.filter(prop => prop.title === propertyTitle)[0];`

I hope that helps 🙂

---

<div class="post-metadata">

**Author:** ![mattgabor](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/mattgabor/32/35877_2.png) [@mattgabor](https://forums.kodeco.com/u/mattgabor)\
**Post date:** [June 30, 2016, 7:49am UTC](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106/38 "2016-06-30T07:49:28Z")

</div>

Any chance this tutorial could be updated for 0.28? It no longer works with the new syntax.

---

<div class="post-metadata">

**Author:** ![imano](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/imano/32/35894_2.png) [@imano](https://forums.kodeco.com/u/imano)\
**Post date:** [June 30, 2016, 1:21pm UTC](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106/39 "2016-06-30T13:21:42Z")

</div>

hi mttmanzo I have the same problem here, and I can’t resolve it, but I wonder if the writer missed some instructions above, for example in render of **SearchPage.js** , onPress function is not defined also for **SearchResults.js** as you have mentionned before!!!

If you can please help me to fix it.  
Tanks !

---

<div class="post-metadata">

**Author:** ![mttmanzo](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/mttmanzo/32/35790_2.png) [@mttmanzo](https://forums.kodeco.com/u/mttmanzo)\
**Post date:** [June 30, 2016, 1:48pm UTC](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106/40 "2016-06-30T13:48:30Z")

</div>

Hi imano, let me show where in the tutorial you can find the implementation on onPress for SearchPage and for SearchResults:

SearchPage, chapter **Initiating a Search** :

 ![](https://raywenderlich-com-v3-forums.s3.amazonaws.com/original/3X/d/b/dbfd9c60ce7215b5e62c1b26f65f261784d84114.png)

if you see, Tom asks you to implement onPress within the TouchableHighlight tag that renders the ‘Go’ text.

---

<div class="post-metadata">

**Author:** ![mttmanzo](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/mttmanzo/32/35790_2.png) [@mttmanzo](https://forums.kodeco.com/u/mttmanzo)\
**Post date:** [June 30, 2016, 1:50pm UTC](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106/41 "2016-06-30T13:50:57Z")

</div>

Instead, in the SearchResults, the implementation is here:

 ![](https://raywenderlich-com-v3-forums.s3.amazonaws.com/original/3X/0/f/0f3fb932832ad0be3d51daabd0739cc06833b11a.png)

Now, if you want to follow my fix, you just have to replace _guid_ with _text_.

Let me know and good luck!

Matteo

[Previous page](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106.md?page=1)

[Next page](https://forums.kodeco.com/t/react-native-tutorial-building-apps-with-javascript/12106.md?page=3)
