Swizec Teller - a geek with a hatswizec.com

Senior Mindset Book

Get promoted, earn a bigger salary, work for top companies

Senior Engineer Mindset cover
Learn more

    Livecoding #30: Dipping my toes in React Native

    This is a Livecoding Recap – an almost-weekly post about interesting things discovered while livecoding ?. Always under 500 words and with pictures. You can follow my channel, here. New streams almost every Sunday at 2pm PDT. There’s live chat, come say hai ?

    After many weeks without Livecoding, we hung out again – all 10 of us. It was great ☺️

    I dipped my toes in React Native and got some help from @nashio and @blackburn1911. They've done it before or had better luck with Google. Both?

    We built a Hello World app that lets you browse through 6 of my Instagram photos. Tap on the right to go next, tap on the left to go previous.

    Sure, it would be more intuitive to swipe, but Snapchat uses taps for going back and forth in stories, and that's my excuse. I also don't know how to make swipes.

    The funny thing about starting with React Native is that googling react native gives you two big results. The official documentation and reactnative.com.

    I clicked reactnative.com and got confused immediately.

    Okay, the new release cadence is monthly. Great! But how do I start using this thing? What do I do next? How do I begin? Do I need Xcode? Can I develop in a normal editor? Should I download a specialized IDE? WHAT DO I DO?

    Then I tried the official docs.

    Get Started With React Native. That looks promising!

    And boy, was it ever. Turns out™ you don't need much to start: node, watchman, and react-native-cli. Docs say watchman isn't mandatory, but it makes life better. ¯\(ツ)_/¯

    You need Xcode for the iOS simulator. If you're doing Android, you'll need that simulator, too.

    Then you run react-native init NativeHelloWorld, and it creates a bunch of things that I don't understand. When you run the simulator with react-native run-ios, a simulator shows up with your new app.

    Simulators, it turns out, are huge. Even on my big fat Apple Thunderbolt display. Maybe I should get one of those new 4K monsters ?

    Running react-native run-ios also opens a terminal with something called React Packager. Don't know what it is, but it looks necessary. I assume it's a compiler.

    Poking around the React Native API was fun, and we learned a few things:

    1. There's no onClick. To detect tap events, you should wrap components in TouchableHighlight, which takes one and only one child element. I think this is silly.
    2. Styling happens through the style= prop. There's no CSS. Or at least the project initiating script heavily promotes avoiding stylesheets.
    3. Layouting through Flexbox is encouraged. I assume you can do whatever you want, and Flexbox is the Best Practice™.
    4. If you use hot loading and add state, you have to reload the app. Otherwise, render() gets called without state getting initialized. That was a fun gotcha.
    5. Images don't size themselves. Without sizing, they're invisible.
    6. Debugging happens in a browser window, not the simulator. This feels funny.

    Overall, I'm impressed with how easy it was to get started. If you know React, you should be able to build cool stuff.

    Now we’ve just gotta figure out why index.android.js is separate from index.ios.js, learn more mobile development principles, then get an interesting project to poke at.


    Published on January 17th, 2017 in Front End, Livecoding, react, Technical

    Did you enjoy this article?

    Continue reading about Livecoding #30: Dipping my toes in React Native

    Semantically similar articles hand-picked by GPT-4

    Senior Mindset Book

    Get promoted, earn a bigger salary, work for top companies

    Learn more

    Have a burning question that you think I can answer? Hit me up on twitter and I'll do my best.

    Who am I and who do I help? I'm Swizec Teller and I turn coders into engineers with "Raw and honest from the heart!" writing. No bullshit. Real insights into the career and skills of a modern software engineer.

    Want to become a true senior engineer? Take ownership, have autonomy, and be a force multiplier on your team. The Senior Engineer Mindset ebook can help 👉 swizec.com/senior-mindset. These are the shifts in mindset that unlocked my career.

    Curious about Serverless and the modern backend? Check out Serverless Handbook, for frontend engineers 👉 ServerlessHandbook.dev

    Want to Stop copy pasting D3 examples and create data visualizations of your own? Learn how to build scalable dataviz React components your whole team can understand with React for Data Visualization

    Want to get my best emails on JavaScript, React, Serverless, Fullstack Web, or Indie Hacking? Check out swizec.com/collections

    Did someone amazing share this letter with you? Wonderful! You can sign up for my weekly letters for software engineers on their path to greatness, here: swizec.com/blog

    Want to brush up on your modern JavaScript syntax? Check out my interactive cheatsheet: es6cheatsheet.com

    By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❤️

    Created by Swizec with ❤️