šŸ“ŗ Introducing Spotern App ā€” Get Any Product Youā€™ve Seen on TV with React Native!

Charles D. Mangwa
The React Native Log
7 min readDec 20, 2017
ā€œWomenā€™s clothes storeā€ ā€” Hannah Morgan

2017 is coming to an end and I have one more thing to share with you! Something Iā€™ve been working on for the past 10 months. Something Iā€™m really proud of. Something Iā€™ll be able to think about in 10 years and tell myself: ā€œYou did something great there, sonā€.

šŸŽ‰ Introducing Spotern: the app that helps you find all the products youā€™ve seen in movies, series, music clips and TV shows! šŸ¾

Project: Spotern šŸ”

Spotern is a one-year old startup based in Paris, France. Its founder Nicolas got the idea while watching The Girl With The Dragon Tattoo: he really liked the jacket Daniel Craig was wearing in a scene, but didnā€™t know how or where to find it.

But wait. What if we could have a platform where we could find every single product that appears on screen? And if we donā€™t find it there: just ask the community to find it for us? Maybe gather some infos about an artist, a movie, a TV series, ā€¦ in a single place? Well, thatā€™s the 3 core elements of Spotern in a nutshell: Spots, Wanted & Medias.

The team quickly felt the need for a mobile app that could backup the already existing web app. This is where yours truly comes into play.

My mission was to build a mobile app for our 50 000 contributors, on both iOS & Android, using React Native.

I used to work on small iOS-only projects, with other developers helping me, so this one was a big undertaking for me: being all by myself on a project of that scale.

So this post is not going to be particularly technical like my previous ones. This time, Iā€™ll try to write a bit more about how I built things with React Native. I really want to focus here on the tools I used to build Spotern.

Language: JavaScript āš›ļø

Spotern is one of those apps that would have been a living nightmare to build solely with native. We had around 30+ screens to implement and doing it twice for both iOS & Android would have been really cumbersome. From there, React Native was probably the most obvious option. Iā€™ve already written a post where I detail some benefits of this framework and (subjectively) compare it to its competitors, back in January.

Navigation: React Router Navigation ā›µļø

This one also was a simple choice. Iā€™ve been working for a few months with LĆ©o Le Bras on a new router for React Native that allows you to use React Router on mobile apps. Long story short: itā€™s Just Componentsā„¢. Components everywhere. Even if we consider it production ready, the router is still in its early age so its not perfect and everything, but weā€™re working on it. I had the opportunity to give a lightning talk about this during react-europe 2016 (thereā€™s also a full recap in a previous post, if youā€™re not really a video person):

Typing: Flow šŸ”®

Here we have a subject thatā€™s getting more and more popular in the JavaScript ecosystem: type checking. JavaScript relies on dynamic typing. Hower, for several REasons *winky face*, static typing is becoming a trend. Usually youā€™ll have 2 options to implement it: TypeScript or FlowType.

I personally opted for Flow because I found it easier to get started with (simply add a `/* @flow */` comment at the top of your .js file), much less obtrusive than TypeScript, it has a better type inference and it can be added gradually to your project file by file.

If you happened to be interested in type checking and want to take it to the next level: you might really be interested in ReasonML šŸ˜. Here is a great talk by bloodyowl that perfectly makes the link between the weaknesses of JavaScript (i.e.: its type system), and how ReasonML solves these problems and much more:

Time: date-fns ā³

Dates & time are a core element of our app. Especially inside the blog section where articles & categories are sorted by creation date. So: thatā€™s something we donā€™t want to break, ever.

When we talk about date libraries in JavaScript, Moment.js tends to be the most popular one. It has tons of features & functionalities that lets you do basically anything with dates.

It was my go-to library for the past 2 years, but it has some limitations: mutability, a complex object-oriented API, bundle size, etc. Thatā€™s why I switched to date-fns whose key features struck a chord with me: immutable & pure, modular, ship with Flow & TypeScript types and an incredibly simple API.

Instead of writing something like this:

import moment from 'moment'const randomBirthday = moment("20171031", "YYYYMMDD").fromNow();

Iā€™ll rather go with:

import distanceToNow from 'date-fns/distance_in_words_to_now'const randomBirthday = distanceToNow(new Date(2017, 10, 31))

Analytics: Fabric šŸ“Š

Tracking usersā€™ interactions is a fundamental need of any app in production. After a little benchmark, I started with Firebase which seemed to be the most convenient solution for analytics with React Native. Unfortunately, at some point I faced some conflicts between Firebaseā€™ config, Google SignInā€™s config and our back-end auth system.

As a result, I had to remove Firebase and find another solution, which was: Fabric. After being acquired from Twitter by Google back in January 2017, Fabric evolved a lot to become the great tool we have now.

Our marketing team is really happy with the result of this switch: segmentation has never been that easy to configure and visualize, events and categories are pretty simple to generate & track, and the #1 selling point: weekly reports come with emojis!šŸ‘Œ They are so happy with it they are even talking about ā€œalso switching the web app analytics system over Fabricā€. šŸ˜„

Data: React Data Fetching šŸŽ£

Data fetching. Thatā€™s probably the core element of any application. Iā€™ve been doing it in a variety of ways in the past but today, I might have found something I really like.

Keeping the Just Componentsā„¢ state of mind Iā€™ve been using with React Router Navigation, Iā€™ve built a component that fetches data. I find this way of fetching data so convenient that I extracted this component from our codebase, to open source as a standalone library: react-data-fetcher šŸŽ‰

A component-driven way to fetch data in React!

This library will probably get its own Medium post when itā€™ll hit npm, because thatā€™s something Iā€™ve been thinking about for a long time and itā€™s worth it. Iā€™m still polishing the final details before publishing it, but here is a little glimpse of what youā€™ll be able to doā€¦ šŸ‘€

<Fetch
path={`${API}/${category}/featuredArticles`}
params={{
method: ā€˜POSTā€™,
body: {
language: ā€˜enā€™,
start: 0,
limit: this.state.limit,
categoryID,
},
}}
refetch={this.state.isRefreshing}
onLoading={this._renderLoadingModal}
onFetch={this._saveData}
onError={this._renderErrorModal}
/>

EDIT 03/15/2018: I just published it!

Starter: React Native Simple Kit šŸš€

When you start working on a React Native project, your first reflex could be to use tools like Expo or create-react-native-app. They work well with iOS and Android, theyā€™re backed by a great community, and are always up-to-date with React Native.

However, there are some apps like Spotern that need something a bit more complex. And as we saw earlier, Iā€™ve already been using a lot of custom tools. So while working on this app, I felt the need for a handcrafted starter kit that could help me with my future projects. Thatā€™s why Iā€™m thrilled to introduce another open source project that comes from my work at Spotern:
react-native-simple-kit šŸŽ‰.

Get started with React Native and Redux with no effort!

Iā€™ll let you discover the boilerplate in the README.md but the idea is to have right out of the box, a starter with all the components, helpers, unit tests, project structure, Redux & ESLint configs I need for any React Native app I could possibly be working on. This boilerplate represents pretty well how I usually build my apps now. Let me know what you think about it!

Thatā€™s all folks! Spotern is now available on both iOS and Android: dont hesitate to give it a try and give me your feedback! Feel free to contact me here or on Twitter @Charles_Mangwa to share your thoughts about the article and the app. Anyhow Iā€™ll hope youā€™ll like what youā€™ll see!

--

--

Charles D. Mangwa
The React Native Log

React Native lyricist āš›ļø, part-time sneakerhead šŸ‘Ÿ