Go From Zero To Hero: Be Cross-Platform Devs With React Native
AI Generated Video Summary
Cross-platform development allows you to build apps compatible with multiple devices or operating systems, reusing 50 to 80 percent of your code. React Native has a wide range of third-party libraries for using APIs. Code examples cover React Native standalone case and with content management system, exploring built-in core components and third-party library APIs. Content management systems simplify content editing and asset swapping, allowing real-time editing and easy asset uploads. The importance of knowing built-in APIs for mastering cross-platform technologies and building scalable, easy-to-maintain applications is highlighted.
1. Introduction to Cross-platform Development
Hi, everyone. Thanks for watching my talk. And less than 10 minutes from now, let's have a look at Go From Zero to Hero, the cross-platform developers with React Native. My name is Arisa, and I'm a DevRel engineer at Storyblock.
So there are three takeaways from my talk. The first takeaway, cross-platform development potential. Second takeaway, ecosystem and cross-platform development technologies. And the third takeaway will be React Native examples.
There are a few notes that I want you to keep in your mind. So this talk is for the cross-platform and the React Native beginners. And the purpose is to aim for showing more front-end technology possibilities. And lastly, I'm going to mainly show you the Web and mobile OS examples.
So what is cross-platform development? First of all, it is a way to build apps that are compatible with multiple devices or operating systems. So let me tell you this, if you build the applications with cross-platform technologies, you can actually reuse 50 to 80 percent of your code. And a cross-platform application like Discord actually has 74 million downloads. And not just only Discord. There are multiple numbers of cross-platform build applications, but here's the little comparison with native apps. So WhatsApp, Messenger, Snapchat, they have quite close numbers of downloads. But you could see how scalable the cross-platform application could be.
2. Comparison of Ionic and React Native
Ionic provides fully adapted components, while React Native has partially adapted components. The point is to choose the best option depending on your cases. React Native has a wide range of third-party libraries for using APIs. Do your own research to find the best approaches and technologies.
On the other hand, Ionic will ship actually with loads of pre-built. The other difference is the other example would be like the React Native actually has partially adapted components while Native Script can provide mostly adapted components. And also Ionic also provides differently, such as fully adapted components. If you see these comparisons, then you might wonder why you're going to talk about React Native. It doesn't sound like the best technology out there. But the point is not to push you to use the one certain technology that I like to use. It is not the point. The point is choosing the best option depending on your cases. And the examples, pros and cons comparison I showed you is just very little information. We are going to see React Native has quite outstanding numbers of the third party libraries to use the APIs on the fly, etc. I would let you do your own little research about choosing the best approaches and technologies out there.
3. Code Examples and Third-Party Libraries
Let's move on to the code examples. We'll see two examples: React Native standalone case and with content management system. We have two options for previewing our applications: Snack, which works on the browser, and X-Bot, an app for previewing on a physical device. We'll cover the use of built-in core components like view, image, stylesheet, and pressable. The pressable component is unique and can handle various touch events. We'll also explore third-party library APIs, focusing on modifying images from the camera roll and saving them to the media library.
But let's move on to the fun part, code examples. We are going to see two examples in this talk. The first one will be React Native standalone case and the other one will be with content management system.
Let's have the options first of all to preview our applications. There are two options that I would like to introduce you. The first one is called Snack, which works on the browser. So you're going to see from this Snack preview that within different OS, in this case minimum three of them can share one code, and you can have the same preview. Moving on to the physical device, you know, like a preview option. In this case I installed an app called X-Bot, and that's why you can see my mobile device in the screen, that I can actually have a preview of the application that I am building right now.
Moving on to the use built-in, moving on to the example of using the built-in core components, and don't worry about if you don't know anything about basic components or pressable, written in here, we are going to cover, you know, like, what is necessary, you know, like, to have the information and have the understanding of the content you're going to see. So this view component will work as a reference component, and this image component stands for what you could imagine to render the image components. This style sheet would also represent, as you could guess, CSS style sheets. This pressable component is a little bit unique because that's something you probably didn't have to consider about, you know, like, web and web applications. So it works as an alternative of the button, but it will detect, you know, more various touch events such as single touch or long press. And here's the pressable component example based on what we learned together along with the other components. So when you choose, when you click this choose photo text, and it will prompt an alert, and should work all the same in the different OSes, iOS, Android, web. And the point is, I brought this text component with the pressable component that you can call as an API. And by doing so, you can do all the same, you know, you can apply, you know, all the same features into the different OSes.
Moving on to the third party library API examples. In this case, we are going to see two examples. But like I said, React Native has really an outstanding numbers of third party library APIs available. But to make things, you know, like simple, we're going to have a look at two APIs to build this up to modify the images that you select from the camera roll, then, you know, like change the size or scale from the editor and you can save that into the camera roll. And moving on to the workflow part, so there are three steps. So first of all, let's check or request the permissions to access to the media library. So to do that, let's use an API, media library. And with a combination of the hook code use permissions, you'll be able to ask the permissions or request the permissions to access to the camera roll. And moving on already to the second workflow, which is saving the files at the user's media library. And to do that, again, use the API, media library. But this time we are going to use save to library async. So by calling this functionality, you will be able to save the files at the given local URI, to the user's camera roll.
4. Workflow, Content Management, and Summary
The last workflow involves taking a screenshot of the view using the useRef hook and the capture ref API. Cross-platform development is based on the component-based approach with similar syntax and advanced app-ready APIs. Content management systems simplify content editing and asset swapping, allowing real-time editing and easy asset uploads. Implementing this logic involves initializing the API, obtaining the access token, and rendering dynamic components. The talk's summary highlights the importance of knowing built-in APIs for mastering cross-platform technologies and building scalable, easy-to-maintain applications. URLs for trying out the examples are available in the GitHub report.
Last workflow would be like taking a screenshot of the view and return the image. And to do that, we can use actually the hook provided from the React Native site called useRef, so this useRef would be able to return the mutable ref object. And this object would be persisting for the whole lifetime. And let's use together with the capture ref API to take the screenshot of the view and return the image for the users.
So based on what we saw together, remember what we learned. So almost all of them are based on the component-based approach. So syntax is almost the same, and you saw advanced app-ready APIs are already prepared for you.
So moving on to the other example together with the content management system, I need to tell you actually so far you need to help editing the content, which is a nightmare. But here's the good news for you. You do not need to do that. If you serve the content from the content management system, because CMS will serve content across different devices and always from the one place. And here's the example, you can see that. So your content editor will be able to access to, let's say, like in this case, Visual Editor on the SOAR block, and they can edit the content in real-time. Of course swapping the assets also would be very easy because there is the UI ready for the users to do that. So they can upload any kind of assets if they want to.
So to implement these kind of logic, here's all the secrets behind. The configuration would be a little bit different depending on the content management system you choose. But the example you saw with the SOAR block would be initialising the API coming from content management system, get the access token, and render the dynamic components.
So here's the summary of my talk. Knowing the built-in APIs will give you the shortcut to master the cross-platform technologies. You saw how you can build a scalable and easy to maintain applications with cross-platform technologies. So that will be all actually about my talk, and if you're interested in to try out some of the examples Vimo and showed you, there are URLs available in the GitHub report.