Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Getting Started with React Native

You're reading from   Getting Started with React Native Learn to build modern native iOS and Android applications using JavaScript and the incredible power of React

Arrow left icon
Product type Paperback
Published in Dec 2015
Publisher
ISBN-13 9781785885181
Length 172 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Structuring the application

It's time to add a little interactivity to our application. You can begin by adding a simple button component to the screen that is touchable. In the root directory, create a folder called App and another folder inside the App folder called Components. In the Components directory, add a file named SimpleButton.js. This will be the directory in which we store and reference the components we create.

Note

Note that the React Native code created in this chapter will work for both iOS and Android. Simply replace index.ios.js with index.android.js if you are interested in android only. The screenshots and instructions will be mainly for the iOS simulator.

Creating the SimpleButton component

Let's start by rendering some text to the screen and importing it into our index.ios.js file. In SimpleButton.js, add:

import React, {
    Text,
    View
} from 'react-native';

export default class SimpleButton extends React.Component {
  render () {
    return ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image