Creating a WooCommerce Mobile App with React Native

A presentation at WooSesh 2018 in October 2018 in by Muhammad Muhsin

Slide 1

Slide 1

Creating a WooCommerce Mobile App with React Native Laccadive IO

Slide 2

Slide 2

Muhammad Muhsin Colombo, Sri Lanka Co-Founder, Laccadive IO Author, Smashing Magazine muhammadmuhsin.com @muhsinlk m-muhsin Laccadive IO

Slide 3

Slide 3

About today’s app Built with React Native Powered by WooCommerce Runs on iOS and Android Shopping cart functionality Laccadive IO

Slide 4

Slide 4

First, what is React? An open-source JavaScript library built by Facebook Helps you build User Interfaces Replaces the view layer of your application Declarative, Composable and Reusable Components Write HTML (JSX) within JavaScript Virtual DOM Laccadive IO

Slide 5

Slide 5

“Write programs that do one thing and do it well.” - Doug McIlroy Laccadive IO

Slide 6

Slide 6

What is special about React Native? Aimed for web developers who want to get into mobile apps Build truly native apps running on iOS and Android Learn once, write anywhere Build with your favorite language (JavaScript) Native performance & look-and-feel Oh, and it has MIT License! Laccadive IO

Slide 7

Slide 7

Features Cons RN Components map to Native Components Not all components are mapped Flexbox for styling Can’t use all CSS properties Native development, when you need it New and rapidly evolving Use other JS libraries along with RN Live Reloading and Hot Reloading Props and State Lifecycle Hooks Laccadive IO

Slide 8

Slide 8

A React Component A Hello World component with React Laccadive IO

Slide 9

Slide 9

A React Native Component The same component in React Native Laccadive IO

Slide 10

Slide 10

Laccadive IO

Slide 11

Slide 11

Who is using React Native Facebook Skype Uber Eats SoundCloud Laccadive IO

Slide 12

Slide 12

Future of React Native iOS Android Windows React Component React Native Tizen macOS Web Laccadive IO

Slide 13

Slide 13

WooCommerce One of the most popular WordPress plugins Powers 28% of the online stores in the world Easily set up your e-commerce store REST API ready https://docs.woocommerce.com/document/woocommerce-rest-api/ https://woocommerce.github.io/woocommerce-rest-api-docs/ Laccadive IO

Slide 14

Slide 14

Let’s Code Laccadive IO

Slide 15

Slide 15

Setting things up Install WooCommerce and SSL Follow the wizard and import sample products WooCommerce Settings > API > Keys/Apps > Add key Note down the Consumer key and Consumer secret https://woocommerce-store.on-its-way.com/ Laccadive IO

Slide 16

Slide 16

Context API Pass down data without using props React.createContext Provider Consumer Laccadive IO

Slide 17

Slide 17

Starting a React Native project npm install -g expo-cli expo init woosesh-store Select ‘tabs’ cd woosesh-store expo start Install and run Expo on your phone and scan QR code OR Run on iOS simulator / Android emulator Laccadive IO

Slide 18

Slide 18

Installing Dependencies npm install -S axios react-native-htmlview Laccadive IO

Slide 19

Slide 19

Home screen A simple image slider Button Laccadive IO

Slide 20

Slide 20

Products page React Native FlatList CSS Flexbox https://woocommerce-store.on-its-way.com/wp-json/wc/v2/ products?consumer_key=ck_286be1c0fd553c4b803ba2b 12c72593eb4676f8d&consumer_secret=cs_d4cc172fabae ef203a78f119518df0453753db65 Laccadive IO

Slide 21

Slide 21

Single product Item and quantity count maintained in state Add to cart button Laccadive IO

Slide 22

Slide 22

Cart page React Context API Laccadive IO

Slide 23

Slide 23

Where to find this project ⭐Star on GitHub: https://github.com/m-muhsin/woosesh-store Read the article: Google for ‘react native wordpress’ https://www.smashingmagazine.com/2018/05/building-mobile-apps-using-react-na tive-wordpress/ Laccadive IO

Slide 24

Slide 24

Go ahead and try! It’s not that hard. Laccadive IO

Slide 25

Slide 25

Thank You! Laccadive IO

Slide 26

Slide 26

Questions? @muhsinlk Laccadive IO