HIGH-PERFORMANCE GRAPHICS WITH REACT NATIVE SKIA
Published: 2022-02-18 18:53:00



# Goals

React native SKIA still in alpha and this article will only cover the benefits of skia to React Native developers.

# Introduction;-
> React Native SKIA would be able to integrate the SKIA library into React Native, which would make many challenging and impossible React Native tasks much easier. I think i would point out the fact that this is my first article without any code, I was uneasy at first but pretty fine writing.
> 

In react native, graphics have been a pain in the neck. I must say that SKIA represents a significant innovation. With SKIA, it only takes a few lines of code to produce amazing visuals; producing stunning and professional-looking applications would no longer require a large amount of code.

One of Facebook's self-proclaimed biggest mistakes was believing so much in HTML over NATIVE, well you could ask why? Retrieving data on a mobile version of Facebook was slow and at the same time unstable. React-Native was created as a result of this.

It allows developers to freely use the React framework in accordance with native enablements or capabilities when developing for Android, iOS, and Windows, although React-Native has a number of limitations. The React-Native Skia library comes into play here.

Since React Native SKIA is currently in alpha, we would have to wait for its full production before using it to construct something distinctive and sophisticated at the same time. But what does the React-Native Skia library have to offer the React-Native development environment before that happens? This article elaborates on that.

## Do you want to try it before its release? You can follow the steps below:

Let's set up a development area for React Native, since React Native Skia project was recently focused on Ubuntu 18 to speed up project development, during your set up of React Native development areas you may encounter a KVM error while trying to run AVD in Android studio, there are quick fixes out there and you can also try this:
Open your Terminal

    Sudo apt install qemu-kvm and run this
    Add user "username" kvm replace "username" with your name and run this
    Restart pc

Hope this turns out just fine for you, if this doesn't work out simply contact Ubuntu developers to help you out.
We would need to install REACT NATIVE SKIA but then I wouldn't go into that as [Shopify](https://shopify.github.io/react-native-skia/) has done a great job making available the installation process available, you can simply use this link.

## React Native Skia

The rendering engine of Google Chrome is powered by SKIA. It is advised that you keep in mind that SKIA powers anything you view on the Google Chrome browser. The fact that Flutter is based on SKIA also explains the previous advantage it had over React Native. React Native Skia allows for a number of previously impossible tasks to be completed by integrating the Skia library and all of its features with React Native.

## Things You Can't Do With React Native

Before we talk about how revolutionary Skia would be in React Native, it seems important to point out a list of Advanced 2D use cases that cannot be accomplished on React Native.

## Graphics Performance

2D graphic capabilities are a hole to feel and SKIA has a handful of solutions to offer. Graphics are one of the most tiring weaknesses in React native.

## SVG and Inset Shadows on Android

Making certain apps where you get to render huge SVG's would result in bottle-necked performance. As a fan of neomorphic designs, I frequently come into difficulties with drop shadows on Android. This is a basic feature that has, for a considerable amount of time, gone unattended. On a competent smartphone, graphics can operate at a rate of five frames per second. Not the best you wish for.

## Text Animation

This is a problem with React Native since there have been numerous projects and libraries created to address it, but their success and outcomes were hardly sustained because each one had its own solutions that didn't withstand the test of time.

# What To Expect From The Skia Library

React native SKIA would provide us with these;-

## Lower Number Of Required Lines Of Code

Here I will provide an example of how Skia would enable streamlined code. I think a good example of this will be charting. Take a look at how much code it requires to create in Skia (from examples in Shopify/React-native-Skia repo) and then take a look at the average animated linear chart library code. It is clearly streamlined.

## High Performance

Both on Android and IOS, SKIA offers significantly superior performance, but it is more obvious on Android. Many programmers believe JavaScript to be slow, however React Native SKIA makes it seem considerably faster. It is anticipated that this will require extensive optimization to work flawlessly. Not to overwhelm us, but switching back to ordinary React-Native (without Skia) would be much more challenging; after all, who doesn't prefer an easy path?

## Inset Shadow

With react native SKIA we can always inset shadows, it's amazing because it's not just a box-shadow implementation we get from this library, it's a general-purpose Integration we could use to create any high-performing graphics. In cases where you want to customize UI components with a bit of styling here and there and some primitive like shadows. Instead of doing all of this, you write a maximum of five lines of skia and you are out there.

## Text Animation

Text animation is made easier as we get animation by default. This would allow us to build incredibly smooth 2D animations for React Native and also be able to use a React like API Declarative syntax.

## Why Is This So Hyped?

I'll provide a very general explanation of why this is so hyped: with this integration, we'll be able to close the gap in the React Native framework.

React Native excels at interacting with UI elements, including complicated animation, but it struggles when dealing with arbitrary motion, such as drawing and rotating an Octagon, because it cannot be readily descended from a native UI element. This is where Skia comes into action. I only hope you understand that it gives you access to an engine like Web Canvas to handle situations like these.


# Conclusion

I outlined a few issues that developers face in our previous sub-topic, as well as all of the potential remedies SKIA offers for us.
We were able to highlight what React Native could not do, and the Skia library for React-Native is a wonderful addition. We also went through the installation procedure. Special thanks goes out to Chris, Williams, and all the React Native developers; this is a significant development.